I have installed the dutch local (nl_NL utf8
) on my webserver (when I execute locale -a
I see nl_NL utf8
so this is allright).
However, the dates on my webpage are in english (I have put setlocale(LC_ALL, 'nl_NL');
in the top of my pages). I have read when you install a locale package after compiling php, I have to recompile php.
But is there any other solution, without recompiling php, to let it work?
Thanks!
The setlocale() function of the PHP programming language usually works by returning the locale information with the help of the two mandatory parameters. It just returns the locale information/info. The return value of the setlocale() function is the current locale settings but on failure, FALSE will be returned.
A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use.
I summarize here what I have found facing a similar problem, since here there have been apparently no constructive answer (a wrong one, indeed: setlocale()
does change the output of strftime()
) and it can be useful for others.
PHP manual says
Return Values
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 for the diagnosys, first check that the right locale is installed (nl_NL, nl_NL.UTF-8, etc.), either using a shell or in PHP system('locale -a')
. On some ubuntu systems there is a script to install a locale, eg. /usr/share/locales/install-language-pack nl_NL
but installing with apt-get may be considered too.
(For exotic locales, also check that locale is supported: on some systems /usr/share/i18n/SUPPORTED
).
Then you can get the output of setlocale() using var_dump(setlocale('nl_NL'));
(since setlocale()
alone doesn't output anything).
For the cure could be to regenerate locale with locale-gen nl_NL, nl_NL
Thereafter, update-locale
(and dpkg-reconfigure locales
) can be required on some systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With