For who have experience with localization and gettext function
I use a WAMP server on Windows and make a test project. I have these files in the website folder:
C:\wamp\www\project\locale\ar_EG\LC_MESSAGES\messages.po C:\wamp\www\project\locale\en_US\LC_MESSAGES\messages.po
Below is the PHP Code:
$language="en_US";
$encoding = "UTF-8";
putenv("LANG=".$language);
setlocale(LC_ALL,$language);
$domain="messages";
bindtextdomain($domain,"Locale");
bind_textdomain_codeset($domain, $encoding);
textdomain($domain);
echo gettext("name");
Above code is working fine. When I try to replace
en_US with
ar_EG it also displays the translation for
en_US, and when I try to remove the
en_US folder and try again it displays the
msgid not
msgstr.
I searched and found that there is a problem with
setlocale function on the Windows platform, but I need a solution for it to run on Windows , any idea ?