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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值