nginx_accept_language_module
nginx_accept_language_module copied to clipboard
2-letter code insufficient for locale
For some major languages, 2-letter code is inadequate/insufficient.
Consider the Chinese language, which has 2 scripts, simplified and traditional. Those would be described as 5-character locale code zh-cn, zh-sg (simplified) and zh-tw, zh-hk (traditional).
It would be nice if your module could work with 5-character locale codes and some kind of user-defined locale-to-locale mapping.
You can see an example of my method I wrote in PHP Language Detector.
For some major languages, 2-letter code is inadequate/insufficient.
@peterkahl, I encountered your same problem, and after reading the code trying to patch it, I realized this lib can handle any characters in locale code, all you need is a simple workaround by listing the languages in ordering from specific to general. (locale with more character in front)
However, the ordering is important for specifying the default locale. For my case, en is the default but I cannot put en in front of en-GB so I use en-US as the first. In this way, en-US is merely an alias for en.
set_from_accept_language $lang en-US en-GB en zh-TW zh ja;
Hopefully this can solve your problem as well.
Thanks for the heads up. At this moment I am using regular expressions to achieve the desired effect.
On 11 May 2016, at 19:46, kimjuan [email protected] wrote:
For some major languages, 2-letter code is inadequate/insufficient.
@peterkahl, I encountered your same problem, and after reading the code trying to patch it, I realized this lib can handle any characters in locale code, all you need is a simple workaround by listing the languages in ordering from specific to general. (locale with more character in front)
However, the ordering is important for specifying the default locale. For my case, en is the default but I cannot put en in front of en-GB so I use en-US as the first. In this way, en-US is merely an alias for en.
set_from_accept_language $lang en-US en-GB en zh-TW zh ja; Hopefully this can solve your problem as well.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub