Reputation: 2854
Are there guidelines or state of the art ways to localize a PHP/MySQL website?
The idea here is to translate buttons, page titles and messages. The language of the website would be chosen at installation time and shouldn't change.
I have started creating text files containing lists of keywords with their translation, but it feels like reinventing the wheel.
Thank you for your help.
Upvotes: 2
Views: 496
Reputation: 2854
In the meantime, I found about an efficient way to build the array text file.
Wherever I want to translate a text item, I use the php gettext() function aliased _() to encapsulate it.
Then, with poedit I parse all my php files an create the translations automatically.
My generated .po (human readable) and .mo (compiled) localization files are put in:
locale/en_EN/LC_MESSAGES
I then initialize my translation application with this code:
$locale = 'en_EN';
putenv("LC_ALL=".$locale);
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "locale");
textdomain("messages");
PROS:
Upvotes: 1
Reputation: 564
I did it once , I have added different file for different language.
Include that file , if no file included then include default (English) file.
And in that file define array ,
$array_language['welcome_msg'] = 'You are welcome';
So which file you'll include that array will show , related message else it will show default English file.
Upvotes: 2