gpt4 book ai didi

java - Java 仍在使用的已弃用语言代码列表在哪里?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:27:12 29 4
gpt4 key购买 nike

根据 Android Locale documentation :

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.

我正在尝试设置我的服务器以支持当前代码(希伯来语 = he)和已弃用的代码(希伯来语 = iw)。上面示例中的三种语言是我唯一需要复制的语言还是有完整的列表?

最佳答案

Java 本身可以列出语言环境中可用语言的字母代码。

这是一个示例,列出所有支持的语言代码并删除一些我们不想要的代码:

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);
}
}

}

当然这个列表(由 Locale.getISOLanguages() 返回)取决于你的 java执行;所以我会设置一个小的 servlet 来返回这个结果函数调用只是为了能够检查您是否感兴趣的语言当您从一个 Java 平台切换到另一个时,仍然支持。

另请注意文档中对此方法的以下评论:

[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.]

希望对您有所帮助,

关于java - Java 仍在使用的已弃用语言代码列表在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18299201/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com