I want to convert strings to lower or upper case in JavaScript in the locale I wanted. I think standard functions like toUpperCase()
and toLocaleUpperCase()
do not satisfy this need. toLocale
functions do not behave as they should.
For example, in Safari 4, Chrome 4 Beta, Firefox 3.5.x on my system it converts strings with Turkish characters incorrectly. The browsers respond to navigator.language as "en-US"
, "tr"
, "en-US"
respectively. But there is no way to get user's Accept-Lang
setting in the browser as far as I could found. Only Chrome gives me "tr"
although I have configured every browser Turkish locale preferred. I think these settings only affect HTTP header, but we can't access to these settings via JavaScript.
In the Mozilla documentation it says
The characters within a string are converted to ... while respecting the current locale. For most languages, this will return the same as ...
I think it's valid for Turkish, it doesn't differ it's configured as en or tr. In Turkish it should convert "DİNÇ"
to "dinç"
and "DINÇ"
to "dınç"
or vice-versa.
Is there any JavaScript library that satisfies this need? I think it should not only converting correctly in user's locale, but also it should support conversion via a locale parameter. Because developers cannot access to user's configured preferred language.