0

I have a very strange situation with gettext.

I configured an Apache server on a Windows Server 2008. I installed the default XAMPP distribution and tweaked a few settings. The site is running fine all in all but the situation is the following:

  • I have the php_gettext.dll enabled in php.ini
  • I checked if the locale files are correctly located and they are, the site reads them correctly. I used these functions and got the following outputs:

input: var_dump(file_exists('./locale/language_code/LC_MESSAGES/file.mo'));

output: bool(true)

input: var_dump(fileperms('./locale/language_code/LC_MESSAGES/file.mo'));

output: int(33204)

  • The default language is Spanish, but for some reason the site loads the English locale by default ignoring either the Spanish or the Portuguese locales. The parameters are correctly passed through .htaccess. That tells me that the gettext is working but just with English. It has 3 languages and 2 locales. Default Spanish, and English and Portuguese locale files.

I tested the same configuration on HostGator hosting and the site worked fine. The difference is the HostGator hosting is Linux and the client's server has Windows. An OS change is not an option. The problems with the language started when we uploaded the site to the client server.

I tried exec("locale -a",$output); but for some reason $output is an empty array. I am thinking the encoding might be the issue, I'll try changing it but in the meantime this is the code I use for the locale:

if(!$_GET["locale"] || $_GET["locale"] == "es_LA") {
    $locale = "es_LA";
} else if($_GET["locale"] == "en_US") {
    $locale = "en_US";
} else if($_GET["locale"] == "pt_PT") {
    $locale = "pt_PT";
}

putenv("LC_ALL=".$locale.".utf8");
setlocale(LC_ALL, $locale.".utf8");
bindtextdomain("file", "./locale");
bind_textdomain_codeset("file", "UTF-8");
textdomain("file");

Any idea what might the reason be?

4

0 回答 0