Question

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!

Was it helpful?

Solution

This may be by design: setlocale() does not automatically change the output of the format of dates output using date() and strftime(). What it does is localize the weekday and month names, but nothing else.

Can you show some examples of how you output dates, and how they fail to get converted?

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top