Wednesday, June 11, 2014

Java Locale class: Bug, Feature, or?

Multilingual support is one of the basic features of our Eclipse application. We give to user the opportunity to choose his language and country. For example, language can be English (en), and country may be United Kingdom (UK), United States (US) or Canada (CA). Java code, performing this functionality, uses standard Java Locale class. The Eclipse resource file, corresponding such Locale class instance, we named using Locale class toString() method as file name extension. That is, for above example of Canadian English, the extension was en_CA, for France' French - fr_FR, for Russia' Russian - ru_RU, and so on. Similarly, we suppose to get the obvious he_IL extension for Israeli Hebrew language. For our great surprise, we got iw_IL instead!! When I opened Locale class code, I've found the special hard coded snippet, changing the "he" string to "iw". Very strange, and so far it is not clear why it was done.