I use gettext localization like this
$lang = $_GET['lang'];
echo $lang;
putenv("LANG=$lang");
setlocale(LC_ALL, $lang);
bindtextdomain("messages", realpath("../locale"));
bind_textdomain_codeset("messages", "utf-8");
textdomain("messages");
...
echo _("Welcome!") etc.
I can see localization works, because the site can be seen translated in Slovak. However, no mather what is in the $lang variable, the site only is translated in Slovak or not translated at all.
Slovak means whatever .po and .mo files i have in 'sk' folder. I have tried putting different languages in the 'sk' folder, it works and I get different translations. But I cannot make it to take different folder, like 'en' or 'cs'. All other folders are ignored. What am I doing wrong?
P.S. setlocale() returns false, I can't figure out why but that's probably causing the trouble.
setlocale() will return false if your system does not support that locale. You can see which locales your system supports by examining the output of locale -a. The value that you pass in via the lang get var must match one of those locale names.
As Dan says, sk is probably your standard locale which is why that is used even if setlocale returns false..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With