translation problem

Please report bugs here!

Moderator: Thorsten

Post Reply
kerryn
Posts: 2
Joined: Thu Jun 24, 2010 1:58 am

translation problem

Post by kerryn »

I am running phpMyFAQ on an international site using a few languages (http://www.ReciproCoach.com/faq/)

I've worked out how to translate categories by clicking that little green arrow, but the only way I've worked out to translate actual FAQs and their answers into another language is to copy it and then write it again in the other language. That means I end up with two separate entries for the same question, but in two different languages. Am I doing this correctly?

Thanks in advance for your help,

Kerryn
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,

you have to translate the actual entry by changing the language in the editor frontend.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: translation problem

Post by oldperl »

Hi Thorsten,

i have the same issue. You can't translate any entry, no matter in which editor language you are.
While debbuging that issue i changed the addCatecory function (inc/Category.php) a little bit, returning me the id only if there is a query-result.

Code: Select all

public function addCategory(Array $category_data, $parent_id = 0, $id = null)
    {
        if (!is_array($category_data)) {
            return false;
        }

        // If we only need a new language, we don't need a new category id
        if (is_null($id)) {
            $id = $this->db->nextID(SQLPREFIX.'faqcategories', 'id');
        }

        $query = sprintf("
            INSERT INTO
                %sfaqcategories
            (id, lang, parent_id, name, description, user_id)
                VALUES
            (%d, '%s', %d, '%s', '%s', %d)",
            SQLPREFIX,
            $id,
            $category_data['lang'],
            $parent_id,
            $category_data['name'],
            $category_data['description'],
            $category_data['user_id']);
        if($this->db->query($query)) return $id;

        return false;
    }
And so i got the problem with this error-message printed out while sending the translationform.
Duplicate entry '14' for key 'PRIMARY'
It's not allowed in my MySQL-DB to insert another dataset with same id (PHP 5.3.1/MySQL 5.1).

Isn't it better to change this behaviour and to give each entry a unique id?
Building category-tree is still possible using the lang-field.
Or, if you need the crossreference of categories, to add a unique dataset id?

Btw, would you please move this thread to bugs? :-)

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,

works for me. You have to translate the categories first, otherwise it won't work because of the missing cross-references.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: translation problem

Post by oldperl »

Sorry Thorsten,

but it's not working. I can't translate any Category. Using the form to translate Category ends in no db-entry. Only that error is thrown. Please try it using an actual xampp version. My version is XAMPP for Windows 1.7.3 with PHP 5.3.1 and MySQL 5.1.
This is definitly a bug and it's reproducible with the system above and an existing db upgraded from earlier versions of phpmyfaq (used on faq.contenido.org).

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,

I'm working on Mac OS X 10.6.4 with PHP 5.3.3, tested with MySQL 5.1.48 and SQLite 3.6.23.1.

Here are my screenshots:
Bildschirmfoto 2010-08-14 um 08.38.21.png
Bildschirmfoto 2010-08-14 um 08.39.14.png
Bildschirmfoto 2010-08-14 um 08.39.47.png
Bildschirmfoto 2010-08-14 um 08.40.05.png
Could you please provide a "SHOW CREATE TABLE faqcategories" result here?

bye
Thorsten
You do not have the required permissions to view the files attached to this post.
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: translation problem

Post by oldperl »

Thorsten wrote:Could you please provide a "SHOW CREATE TABLE faqcategories" result here?
Shure i can. :-)

Code: Select all

CREATE TABLE `faqcategories` (
 `id` int(11) NOT NULL DEFAULT '0',
 `lang` varchar(5) NOT NULL DEFAULT '',
 `parent_id` int(11) NOT NULL DEFAULT '0',
 `name` varchar(255) NOT NULL DEFAULT '',
 `description` varchar(255) DEFAULT NULL,
 `user_id` int(11) NOT NULL DEFAULT '0',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
For explanation, it's the faq used on http://faq.contenido.org, updated and upgraded from an initial phpmyfaq 1.x or 2.x. I don't know the history exactly.
I'm working on an update to the newest phpmyfaq version on a local xampp server.

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,

ah, this is the issue... the PRIMARY KEY is on id and lang, that's why you get the error message. Here's the correct one:

Code: Select all

CREATE TABLE `faqcategories` (
 `id` int(11) NOT NULL,
 `lang` varchar(5) NOT NULL,
 `parent_id` int(11) NOT NULL,
 `name` varchar(255) NOT NULL,
 `description` varchar(255) DEFAULT NULL,
 `user_id` int(11) NOT NULL,
 PRIMARY KEY (`id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
So, drop the primary key for id and create a new one on id and lang. It could be easily done by using phpMyAdmin. Should be part of XAMPP.

The problem is how to find the version update with the missing primary key update...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: translation problem

Post by oldperl »

Hi Thorsten,

that's it. Now translation is working. Good job, thank you very much. :-)

Btw
Thorsten wrote:you have to translate the actual entry by changing the language in the editor frontend.
You don't have to change either admin nor frontend language for translation. I translated german->english with german interface language.

Last question, have i also to alter table using innodb engine (now it's myisam)?
Are you planing to use any innodb related features of mysql in the future?
Thorsten wrote:The problem is how to find the version update with the missing primary key update...
Maybe it's possible to check tablestatus during update setup and alter table(s) as needed or to give admin a hint?!

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,
Last question, have i also to alter table using innodb engine (now it's myisam)?
no, I'm running ext/mysqli and there is InnoDB my standard.
Are you planing to use any innodb related features of mysql in the future?
not in the 2.x series... but maybe... I don't know yet. :-)
Maybe it's possible to check tablestatus during update setup and alter table(s) as needed or to give admin a hint?!
The problem could be that people running phpMyFAQ on normal shared webhostings cannot check their tablestatus...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: translation problem

Post by oldperl »

Hi,
Thorsten wrote:The problem could be that people running phpMyFAQ on normal shared webhostings cannot check their tablestatus...
That's easy. :-)
Check the right by querying a 'show create'. If mysql throws an error, read 1 dataset out of db (limit 1), change the lang field and try to write it back with the same id. If mysql throws an error, check this for the words 'duplicated entry' and do your mysql stuff as needed.

Other way is to del primary and write it as needed anyway.

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: translation problem

Post by Thorsten »

Hi,

when I'll find some free time I can add this... :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply