PHP have strange support for setlocale()
on different versions.
The tests below is on Windows (same machine), Apache 2.4 x64 (same web server), PHP x64 TS (different versions).
setlocale()
Return:
Returns the new current locale, or false
if the locale functionality is not implemented on your platform, the specified locale does not exist or the category name is invalid.
So, I will use the tests below on different version of PHP. Tested on PHP 7.0 - 8.1.
var_dump(setlocale(LC_ALL, 'en_US'));
PHP 7.0, 7.1 return 'en_US'
.
PHP 7.2+ (or newer) return false
.
var_dump(setlocale(LC_ALL, 'en-US'));
PHP 7.0+ return 'en-US'
.
And for testing with multiple values to see which one will be accepted by setlocale()
function.
I use this array.
$locale = ['en_US.UTF-8', 'en-US.UTF-8', 'en.UTF-8', 'en-US', 'en_US', 'en'];
var_dump(setlocale(LC_ALL, $locale));
PHP 7.0, 7.1 return 'en_US.UTF-8'
.
PHP 7.2+ return 'en-US.UTF-8'
.
As you can see that if PHP did supported 'en_US'
for old version it doesn't mean will be supported on newer version.
For OP's case, maybe try with this array to see which locale will be accepted.
$locale = ['de_DE.UTF-8', 'de-DE.UTF-8', 'de.UTF-8', 'de_DE', 'de-DE', 'de', 'ge'];
var_dump(setlocale(LC_ALL, $locale));
The result maybe different on Linux or other OS.
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
?setLocale