Hi Folks,

I have the following file in my website directory.... as test.php


<?php
// I18N support information here
$language = 'en';
putenv("LANG=$language");
setlocale(LC_ALL, $language);
//setlocale(LC_MESSAGES, $language);
//setlocale(LANGUAGE, $language);

// Set the text domain as 'messages'
$domain = 'messages';
bindtextdomain($domain, "/usr/local/htdocs/mysite/path/to/locale");
textdomain($domain);

echo gettext("A string to be translated would go here");

?>

This code is from one site that explained that how to use "gettext()" to make your site multi-lingual...... however I am not getting the result when I want to print my english site in spanish.....

Here's what I did for the above file.....

I used "xgettext -n *.php" on my linux server which created "messages.po" file......

I moved this file to "/usr/local/htdocs/mysite/path/to/locale/en/LS_MESSAGES/" folder.....

Now I used "msgfmt messages.po" and it created "messages.mo" file in the same directory....

when I run the above script, it gives the same english string..... Now I changed the $language = "es" and as per the instructions, created a "es" folder in the "..../locale" and copied the .mo and .po files to this folder (under LS_MESSAGES).....

Now when I run the script, it does not give me the equivalent spanish string but the same english script.... can anyone please help on where am I missing?

Btw, when I used xgettext command, it gives me a warning that "php - unknown extension"...... several similar warning messages appear when using "msgfmt" command.....

Thanx in advance.....
Ritesh

    Write a Reply...