ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-12-02 01:01:56  阅读:492  来源: 互联网

标签:jdk1-6 locale turkish java


根据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似乎没有这些国家/地区名称的土耳其语翻译.

标签:jdk1-6,locale,turkish,java
来源: https://codeday.me/bug/20191202/2084681.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有