I don't understand what I do wrong. Maybe someone help me. I just trying to follow the instructions, but translate not working.
This is phpinfo(); file: https://equipe.viacast.eu/phpinfo.php
Next I did this:
new file: translate.php
<?php echo _("Good Morning"); ?>
In command line I use this line which does create the .po files directly from the
xgettext -n translate.php
After that if messages.po file will be generated I edit language and the charset line.
"Language fr\n"
"Content-Type: text/plain; charset=UTF-8\n"
Now I add this lines in .PO file:
#: translate.php:2
msgid "Good Morning"
msgstr "Bonjour"
After that I open command line and type this line
msgfmt messages.po
I create next folders:
locale/fr_FR/LC_MESSAGES
and I moved messages.mo and messages.po in this folder:
locale/fr_FR/LC_MESSAGES
Next I edit the translate.php file and I added next lines:
<?php
$locale = "fr_FR";
if (defined('LC_MESSAGES')) {
setlocale(LC_MESSAGES, $locale); // Linux
bindtextdomain("messages", "./locale");
} else {
putenv("LC_ALL={$locale}"); // windows
bindtextdomain("messages", ".\locale");
}
textdomain("messages");
echo _("Good Morning");
?>
After that I open translate.php file in browser and the text has not changed. Still showing "Good Morning" text when it should show "Bonjour"
try
instead of
;-)
And this can also help if you are going to use plural forms: