java - 当 "inLocale"设置为土耳其语 (JDK 1.6.0_29) 时可用的语言环境显示国家?

标签 java locale java-6 turkish

根据 Locale.getDisplayLanguage(Locale inLocale) 的 javadoc ,

Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and inLocale is fr_FR, getDisplayCountry() will return "Etats-Unis". If the name returned cannot be localized according to inLocale. (say, we don't have a Japanese name for Croatia), this function falls back on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.

因此,当我执行以下代码片段时:

final class TurkishDemo 
{
    public static void main(String[] args) 
    {
        final Locale l = new Locale("tr");
        for(Locale locale: Locale.getAvailableLocales())
        {
            System.out.println(locale.getDisplayCountry(l));
        }
    }
}

我得到以下输出:

Japan Peru

Japan Panama Bosnia and Herzegovina

Guatemala United Arab Emirates Norway Albania

Iraq Yemen

Portugal Cyprus Qatar Macedonia

Switzerland United States Finland

Malta Slovenia Slovakia

Türkiye

Saudi Arabia

United Kingdom Serbia and Montenegro

New Zealand Norway Lithuania Nicaragua

Ireland Belgium Spain Lebanon

Canada Estonia Kuwait Serbia United States Mexico Sudan Indonesia

Uruguay Latvia

Brazil Syria

Dominican Republic Switzerland India Venezuela Bahrain Philippines Tunisia

Austria

Netherlands Ecuador Taiwan Jordan

Iceland Colombia Costa Rica Chile Egypt South Africa Thailand Greece Italy

Hungary

Ireland Ukraine Poland Luxembourg Belgium India Spain Morocco Bolivia Australia

Singapore

El Salvador Russia South Korea

Algeria Vietnam Montenegro

Libya

China Belarus Hong Kong

Israel Bulgaria

Malta Paraguay

France Czech Republic Switzerland Romania Puerto Rico Canada Germany

Luxembourg

Argentina

Malaysia Croatia Singapore

Oman

Thailand

Sweden Denmark Honduras

您会注意到几乎所有(土耳其除外)都回退到英文显示国家/地区名称。这是预料之中的,还是我做错了什么?

最佳答案

我认为您的代码是正确的。我在我的机器上运行代码时得到了相同的行为。除了土耳其本身,JDK 似乎没有这些国家/地区名称的土耳其语翻译。

关于java - 当 "inLocale"设置为土耳其语 (JDK 1.6.0_29) 时可用的语言环境显示国家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8591450/

相关文章:

java - 如何从Netbeans java项目制作exe文件以在所有没有JVM的系统中运行?

java - 在 Java 1.6 中使用字符串进行切换

java - 获取实际文件,给定 java6 上的符号链接(symbolic link)

java - 安卓 : how to set DropDown View Resource for Spinner?

java - 我在模拟测试期间收到此错误 : Failed to load ApplicationContext

java - log4j 2 向控制台附加程序添加多种颜色

php - 在 Symfony 2.1 中设置语言环境

java - Dropwizard 示例包编译错误

环境更改后 SwiftUI 更新 LocalizedStringResource 插值(\.locale

presto - 在 JDK 6 上运行 Presto