Where is the list of obsolete language codes that Java still uses?

Per documentation on local Android phone :

Please note that Java uses some outdated two-letter codes. The Hebrew ("he") language code is rewritten as "iw", Indonesian ("id") as "in", and Yiddish ("yi") as "ji". This rewriting happens even if you create your own Locale object, and not just for instances returned by various search methods.

I am trying to configure my servers to support both current codes (Hebrew = he) and outdated codes (Hebrew = iw). Are the three languages ​​in the example above the only ones I need to duplicate, or is there a complete list?

+4
source share
1 answer

Java itself can list letter codes for available languages ​​in locales.

Here is an example to list all supported language codes and remove some codes that we don’t want from the list:

public class TestLocale { public static void main(String[] args) { String[] allLangs = Locale.getISOLanguages(); String[] deprecatedLangs = {"ji", "in", "iw"}; ArrayList<String> validLangs = new ArrayList<String>(Arrays.asList(allLangs)); validLangs.removeAll(Arrays.asList(deprecatedLangs)); for (String lng : validLangs) { System.out.println(lng); } } } 

Of course, this list (returned by Locale.getISOLanguages ​​()) depends on your java implementation; so I would install a small servlet to return the result of this function call just to check if the language you are interested in is still supported when switching from one java form to another.

Also note the documentation for the following comment on this method:

[NOTE: ISO 639 is not a stable standard - some language codes have changed. The list this function returns both new and old codes for languages, codes have changed.]

Hope this helps,

0
source

Source: https://habr.com/ru/post/1497663/


All Articles