At work we have decided to translate our site into 3 additional languages and I have been looking into how to do this. I've spent the better part of the day searching google and stackoverflow, trying every different solution but I can't make it work.
I'm starting to fear that it is impossible to do in Windows 7 Home edition (My development machine).
// C:\Apache24\htdocs\locale\en_GB\LC_MESSAGES\messages.mo
// C:\Apache24\htdocs\locale\en_GB\LC_MESSAGES\messages.po
msgid ""
msgstr ""
"Project-Id-Version: iArbete 1.0.0\n"
"Report-Msgid-Bugs-To: ******** \n"
"Last-Translator: ********\n"
"Language: en_GB\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "iArbete"
msgstr "workIng"
// C:\Apache24\htdocs\index.php
if(isset($_GET["locale"]))
{
$locale = $_GET["locale"];
}
else
{
$locale = 'en_GB';
}
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
echo getenv("LC_ALL");
$domain = 'messages';
bindtextdomain($domain, './locale');
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
echo _("iArbete");
echo _("iArbete");
Should translate to "workIng" but it does not. Or am I not getting the concept?
--- More information --------------------------------------------------------
I've made some changes and recompiled the mo file and this is how it looks now.
// C:\Apache24\htdocs\locale\en_GB\LC_MESSAGES\messages.mo
// C:\Apache24\htdocs\locale\en_GB\LC_MESSAGES\messages.po
msgid ""
msgstr ""
"Project-Id-Version: iArbete 1.0.0\n"
"Report-Msgid-Bugs-To: ******** \n"
"Last-Translator: ********\n"
"Language: en_GB\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "workIng"
msgstr "iArbete"
msgid "Menu"
msgstr "Meny"
// C:\Apache24\htdocs\index.php
if(isset($_GET["locale"]))
{
$locale = $_GET["locale"];
}
else
{
$locale = 'sv_SE';
$locale = 'en_GB';
// $locale = 'ar_AE';
}
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
// echo getenv("LC_ALL");
$domain = 'messages';
bindtextdomain($domain, './locale');
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
echo _("workIng");
echo _("Menu");
msgid "workIng"
is translated to "iArbete"
msgid "Menu"
is not translated to "Meny"
What is going on? It feels so weird that only the first word get translated. So I rearranged the words in the po and recompiled but still "workIng" is the only word that gets translated??
I've uploades my files to google drive here if anyone would like to have a look.