Windows uses 3 character locale names in (PHP 5.3.1 atleast) alomg with language_Country.encoding format for LC_CTYPE:
<?php
echo setlocale(LC_ALL, 0) . "\n";
// LC_COLLATE=C;LC_CTYPE=English_United States.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C
setlocale(LC_CTYPE, 'Bulgarian_Bulgaria.1251');
echo setlocale(LC_ALL, 0) . "\n";
// LC_COLLATE=C;LC_CTYPE=Bulgarian_Bulgaria.1251;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C
setlocale(LC_CTYPE, 'Tamil_India.1252');
echo setlocale(LC_ALL, 0) . "\n";
// LC_COLLATE=C;LC_CTYPE=Tamil_India.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C
setlocale(LC_ALL, "fra_fra");
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));
/* Output nld_nld: vrijdag 22 december 1978 */
/* Output deu_deu: Freitag 22 Dezember 1978 */
/* Output fra_fra: vendredi 22 décembre 1978 */
Pay attention to the syntax.
- UTF8 without dash ('-')
- locale.codeset and not locale-codeset.
<?php
$codeset = "UTF8"; // warning ! not UTF-8 with dash '-'
// for windows compatibility (e.g. xampp) : theses 3 lines are useless for linux systems
putenv('LANG='.$lang.'.'.$codeset);
putenv('LANGUAGE='.$lang.'.'.$codeset);
bind_textdomain_codeset('mydomain', $codeset);
// set locale
bindtextdomain('mydomain', ABSPATH.'/locale/');
setlocale(LC_ALL, $lang.'.'.$codeset);
textdomain('mydomain');
?>
where directory structure of locale is (for example) :
locale/fr_FR/LC_MESSAGES/mydomain.mo
locale/en_US/LC_MESSAGES/mydomain.mo
and ABSPATH is the absolute path to the locale dir
Further note, under linux systems, it seems to be necessary to create the locale at os level using 'locale-gen'.
Ref:
http://php.net/manual/en/function.setlocale.php
https://msdn.microsoft.com/en-us/library/x99tb11d%28v=vs.140%29.aspx