当“inLocale”指定时可用的区域设置显示国家/地区设置为土耳其语(JDK 1.6.0_29)?
根据 Locale.getDisplayLanguage(Locale inLocale)
,
返回适合的语言环境国家/地区名称 显示给用户。如果可能,返回的名称将被本地化 根据 inLocale。例如,如果区域设置为 fr_FR 并且 inLocale 为 en_US,getDisplayCountry() 将返回“France”;如果 locale 是 en_US 且 inLocale 是 fr_FR, getDisplayCountry() 将返回 “Etats-Unis”。如果返回的名称无法根据 在语言环境中。 (比如说,我们没有克罗地亚的日文名称),这个 函数依赖于英文名称,最后依赖于 ISO 代码 作为最后手段的价值。如果区域设置未指定国家/地区,则此 函数返回空字符串。
因此,当我执行以下代码片段时:
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));
}
}
}
我得到以下输出:
日本秘鲁
日本巴拿马波斯尼亚和黑塞哥维那
危地马拉阿拉伯联合酋长国挪威阿尔巴尼亚
伊拉克也门
葡萄牙塞浦路斯卡塔尔马其顿
瑞士、美国、芬兰
马耳他 斯洛文尼亚 斯洛伐克
土耳其
沙特阿拉伯
英国塞尔维亚和黑山
新西兰挪威立陶宛尼加拉瓜
爱尔兰比利时西班牙黎巴嫩
加拿大爱沙尼亚科威特塞尔维亚美国墨西哥苏丹印度尼西亚
乌拉圭拉脱维亚
巴西叙利亚
多米尼加共和国 瑞士 印度 委内瑞拉 巴林 菲律宾 突尼斯
奥地利
荷兰厄瓜多尔台湾约旦
冰岛、哥伦比亚、哥斯达黎加、智利、埃及、南非、泰国、希腊 意大利
匈牙利
爱尔兰乌克兰波兰卢森堡比利时印度西班牙摩洛哥玻利维亚 澳大利亚
新加坡
萨尔瓦多俄罗斯韩国
阿尔及利亚越南黑山
利比亚
中国白俄罗斯香港
以色列保加利亚
马耳他巴拉圭
法国捷克共和国瑞士罗马尼亚波多黎各加拿大德国
卢森堡
阿根廷
马来西亚克罗地亚新加坡
阿曼
泰国
瑞典丹麦洪都拉斯
您会注意到,几乎所有国家(土耳其除外)都下降了返回英文显示国家名称。这是可以预料的,还是我做错了什么?
According to the javadoc for Locale.getDisplayLanguage(Locale inLocale)
,
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.
So, when I execute the following code snippet:
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));
}
}
}
And I get the following output:
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
TunisiaAustria
Netherlands Ecuador Taiwan Jordan
Iceland Colombia Costa Rica Chile Egypt South Africa Thailand Greece
ItalyHungary
Ireland Ukraine Poland Luxembourg Belgium India Spain Morocco Bolivia
AustraliaSingapore
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
You'll notice that nearly all (except Turkey) falls back to the English display country name. Is this to be expected, or am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的代码是正确的。我在我的机器上运行代码时得到了相同的行为。除了土耳其本身之外,JDK 似乎没有这些国家/地区名称的土耳其语翻译。
I think your code is correct. I got the same behavior running the code in my machine. It seems that JDK doesn't have Turkish translations for these country names except for Turkey itself.