It’s not often that I get to work on localization related features or bugs, but when I do, it’s spectacular!
Take the sv-SE (Swedish) locale for example. If you write in the Chrome console the following:
(-1).toLocaleString(“sv-SE”) == “-1”
It will get evaluated to a big fat false. Why? Because the minus character this particular locale is using is the typographic minus, not the usual hyphen that all apps are used to.
Wait what? Yep, and it gets better. As it turns out it’s not even part of the Swedish keyboard layout.
Now, if you do the same thing in IE 11 or the newer Edge it will get correctly evaluated to true.
So what’s going on? The function toLocaleString is browser native, and each vendor has their own implementation. Microsoft use their own proprietary localization data that they had and evolved for a long time. Google on the other hand seem to be making use of CLDR data, as they have the same typographic minus in their definitions.
This isn’t a huge issue if you’re just displaying data, but if you need to constantly parse and re-format user input then it’s going to be a pain, unless you use a dedicated framework.