i am trying to use the php gettext extension in php 5.5 (on win2008 server, using IIS7). I am doing this:
As per not knowing which language pack to use on the OS, thankfully the setlocale() function allows for an array. As per the PHP Docs:
"If locale is an array or followed by additional parameters then each array element or parameter is tried to be set as new locale until success. This is useful if a locale is known under different names on different systems or for providing a fallback for a possibly not available locale"
With this, you can dig to find out locale the OS is falling back to by checking the set after:
$locales = array( "fr_FR", "fr_FR.UTF-8", "fr_FR.utf8", "fr-FR" );
if (( $setTo = setlocale( LC_ALL, $locales )) === FALSE )
{
echo "Unable to set a locale that the OS recognises.";
return false;
}
else
{
echo "Set LC_ALL to " . $setTo; //echos fr_FR.utf8
return true;
}
$setTo will be provided with the $locales value that was successful. This might be helpful when finding which locale to write a .po for.
As per written in my comments, I had the issue where I was not performing this setlocale() at the top of each script of every page request, as you'll need to retain the user's choice of language by session or database value. As I believed naively once it was set, it was set forever!