Part of the confusion here is that PHP has two concepts called "locale" that are pretty much totally separate.
The first is the older one, which basically just uses the C locale features. That's what's behind setlocale
and the locale support in some of PHP's functions (like money_format
for example). This is what other answers that mention running locale -a
on the command line and using setlocale
are talking about.
PHP's Locale
class and the other related functionality from the intl
extension is newer, and doesn't work the same way. Instead of using the libc locale stuff, it uses a library called ICU, which ships its own locale data. PHP does provide a method to determine which locales are supported by this system: ResourceBundle::getLocales. The documentation is a little wooly here, but you can call this as a static method and pass the blank string to use ICU's default resources, thus getting a list of the supported locales for intl
:
ResourceBundle::getLocales('');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…