I have a problem getting gettext to work on Windows Server 2008 R2, PHP 5.5
I do the following in my php script:
$language = 'NB';
putenv("LANG=".$language);
putenv("LC_ALL=".$language);
setlocale(LC_ALL, $language);
$domain = 'messages';
bindtextdomain($domain, 'C:/path_to_translations/translations');
textdomain($domain);
My translation files are in the following directories:
C:/path_to_translations/translations/NB/LC_MESSAGES/messages.po C:/path_to_translations/translations/NB/LC_MESSAGES/messages.mo
This works fine on my Windows 7 machine with php 5.3
I guess NB is not really a valid locale name on Windows, but setlocale(LC_ALL, 'NB') still returns 'NB' and not FALSE. Still, to see if this might have something to do with the problem I have tried setting $language = 'norwegian', in which case setlocale(LC_ALL, 'norwegian') returns 'Norwegian_Norway.1252', and tried to change the pathnames to both C:/path_to_translations/translations/norwegian/LC_MESSAGES/messages.mo and C:/path_to_translations/translations/Norwegian_Norway.1252/LC_MESSAGES/messages.mo and also changing the encoding on the .po and .mo files from 'UTF-8' to 'Windows 1252'. Yet, I can't get the translation to work on the Windows Server 2008 R2, PHP 5.5 machine.
Update. Never got gettext to work with php 5.5, but found other users had similar problems (https://bugs.php.net/bug.php?id=66265)
Tried installing php 5.4 instead, and now things work as expected.