Per Android Locale documentation:
根据Android Locale文档:
Note that Java uses several deprecated 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 construct your own Locale object, not just for instances returned by the various lookup methods.
请注意,Java使用了几个不推荐使用的双字母代码。希伯来语(“他”)的语言代码被重写为“iw”,印度尼西亚语(“id”)被改写为“in”,而意第绪语(“yi”)被改写为“ji”。即使您构造自己的Locale对象,也不仅仅是由各种查找方法返回的实例,这种重写也会发生。
I'm trying to setup my servers to support both the current codes (Hebrew = he) and the deprecated codes (Hebrew = iw). Are the three languages in the example above the only ones that I need to duplicate or is there a full list?
我正在尝试设置我的服务器以支持当前代码(希伯来语=他)和不推荐使用的代码(希伯来语= iw)。以上示例中的三种语言是我需要复制的唯一语言还是有完整列表?
1 个解决方案
#1
0
Java itself can list the letter codes for the avalable languages in the locales.
Java本身可以列出语言环境中可用语言的字母代码。
Here is an example to list all the supported language codes and to 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 set up a small servlet to return the result of this function invocation just to be able to check if the language that interests you is still supported when you switch from one java plaform to another.
当然这个列表(由Locale.getISOLanguages()返回)取决于你的java实现;所以我会设置一个小的servlet来返回这个函数调用的结果,以便能够检查当你从一个java平台切换到另一个时,是否仍然支持你感兴趣的语言。
Note also in the documentation the following comment on this method :
还请在文档中注意此方法的以下注释:
[NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]
[注意:ISO 639不是一个稳定的标准 - 某些语言的代码已经改变。此函数返回的列表包括代码已更改的语言的新代码和旧代码。
Hope this helps,
希望这可以帮助,
#1
0
Java itself can list the letter codes for the avalable languages in the locales.
Java本身可以列出语言环境中可用语言的字母代码。
Here is an example to list all the supported language codes and to 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 set up a small servlet to return the result of this function invocation just to be able to check if the language that interests you is still supported when you switch from one java plaform to another.
当然这个列表(由Locale.getISOLanguages()返回)取决于你的java实现;所以我会设置一个小的servlet来返回这个函数调用的结果,以便能够检查当你从一个java平台切换到另一个时,是否仍然支持你感兴趣的语言。
Note also in the documentation the following comment on this method :
还请在文档中注意此方法的以下注释:
[NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]
[注意:ISO 639不是一个稳定的标准 - 某些语言的代码已经改变。此函数返回的列表包括代码已更改的语言的新代码和旧代码。
Hope this helps,
希望这可以帮助,