如何获取所有Java支持的语言环境 [英] How to get all Java supported Locales

查看:73
本文介绍了如何获取所有Java支持的语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google时,您会发现很多资料,可以找到Java支持的所有语言环境.但这一切令人困惑.

When Google you will find lot of materials to find all the supported Locales by Java. But its all confusing.

例如[http://sanjaal.com/java/tag/java-locale-tutorial/]显示210个语言环境的输出.但是,当我运行相同的程序时,我只会得到155.例如,我不会得到ta_IN.si_LK不由任何程序输出.

For example [http://sanjaal.com/java/tag/java-locale-tutorial/] show an output of 210 locales. But when I run the same program I get only 155. I don;t get for example ta_IN. si_LK is not output by any program.

有人可以放开空气吗?

我使用JDK/JRE 1.7

I use JDK/JRE 1.7

http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html 给出111个条目.

我有一个支持i18n的Spring应用程序,我们的客户可以放置自己的本地化版本.我想做的是提供所有语言环境的列表,以便他们从中选择自己的语言环境.

I have a Spring Application which supports i18n and our customers can put their own localisations. What I am trying to do is to provide a list of all locales for them to select their one from.

哦!这很令人困惑.Local.getISOCountries()提供LK作为国家/地区,而Locale.getISOLanguages();提供LK作为国家/地区.提供si作为一种语言.....,但是Locale.getAvailableLocales();中没有给出有效的语言环境si_LK

Oh! this is confusing. Local.getISOCountries() provide LK as a country and Locale.getISOLanguages(); provide si as a language .... but si_LK which is a valid locale is not given in Locale.getAvailableLocales();

推荐答案

    Locale loc = new Locale("ta", "IN"); // ta_IN, si_LK
    System.out.printf("Name: %s%n"
            + "Country: %s; %s - %s%n"
            + "Language: %s; %s - %s%n"
            + "Script: %s - %s%n",
            loc.getDisplayName(Locale.ENGLISH),
            loc.getCountry(), loc.getISO3Country(), loc.getDisplayCountry(Locale.ENGLISH),
            loc.getLanguage(), loc.getISO3Language(), loc.getDisplayLanguage(Locale.ENGLISH),
            loc.getScript(), loc.getDisplayScript(Locale.ENGLISH));

Name: Tamil (India)
Country: IN; IND - India
Language: ta; tam - Tamil
Script:  - 

Name: Sinhalese (Sri Lanka)
Country: LK; LKA - Sri Lanka
Language: si; sin - Sinhalese
Script:  - 

也可以为自己的语言环境提供支持(因为我相信Java 7是这样).我是为世界语制作的,它是可行的(LocaleProvider).但您的情况可能全部存在.

Also it is possible to provide support for ones own locale (since Java 7 I believe). I made it for Esperanto, and it is doable (LocaleProvider). But in your case all might be there.

    SimpleDateFormat f = new SimpleDateFormat("EEEE", loc);
    System.out.println("Weekday: " + f.format(new Date()));

不幸的是显示星期二",因此需要实现语言格式等.我为 serbo-croatian/bosnian 找到了一个项目.

Unfortunately shows "Tuesday," so one needs to implement the language formats and such. I found a project for serbo-croatian/bosnian.

这篇关于如何获取所有Java支持的语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆