How to add Norwegian to setlocale()?

拈花ヽ惹草 提交于 2019-12-11 05:48:47

问题


I want to add Norwegian date. So that I can have two languages on my website.

According to PHP manual, it says that

The return value of setlocale() depends on the system that PHP is running. It returns exactly what the system setlocale function returns.

How can I add Norwegian ?

Thanks in advance.

I want to use setlocale(), and strftime() as followings. (for Norwegian and English)

setlocale(LC_TIME, "C");
echo strftime("%A");
setlocale(LC_TIME, "fi_FI");
echo strftime(" in Finnish is %A,");
setlocale(LC_TIME, "fr_FR");
echo strftime(" in French %A and");
setlocale(LC_TIME, "de_DE");
echo strftime(" in German %A.\n");

回答1:


You would need to install the Norwegian locale, if it isn't installed yet. How to do that, depends on your server OS.

If the examples you show work already, and/or it's a norwegian server, chances are it is already installed. I would try whether one of no_NO, no_NN (Nynorsk) and no_NB (Bokmål) does the trick.

On a side note though, the very fact that these functions rely so heavily on the underlying OS's setup, and the way to address the language codes/locales varies from system to system (thus adding utter chaos to the program's configuration!), have convinced me that using a PHP-based library like Zend_Locale for this is the much better option.

I'm not sure how well norwegian is supported by it out of the box, but I'm pretty sure adding the necessary resources is easy.



来源:https://stackoverflow.com/questions/3922368/how-to-add-norwegian-to-setlocale

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!