在我看来,默认语言不存在的立场是完全错误的——或者说它对解决手头的问题没有用处。几乎每个国家都有一种官方或事实上的主导语言或国家语言。或者至少可以通过某种方式确定多种语言的优先级。
主要语言应该是什么以及特定语言应该具有什么权重通常是主观的或特定于领域的,并且可能会发生变化。因此,Java 或 Unicode 不提供此信息是有道理的。幸运的是,拥有一种以上语言的国家数量非常少(至少根据我的 JVM 语言环境列表),而且我们确定偏好所需的所有数据都很容易获得。所以我们可以手动指定这些信息。
以下是我的(主观)排名。必须特别注意一些边缘情况,例如塞尔维亚语,因为西里尔语用于官方通信,但更多人可以阅读拉丁语。因此,在某些情况下,您更喜欢哪一个取决于您的用例。
还要注意语言环境存储库和语言使用可能会发生变化,因此此答案可能已过时。
// https://en.wikipedia.org/wiki/Languages_of_Ireland
// English (99%)
// Irish (36%)
setPreference("IE", "en_IE", 0.99) // English
setPreference("IE", "ga_IE", 0.36) // Irish
// India
// https://en.wikipedia.org/wiki/Languages_of_India
// Hindi (57.1%)
// English (10.6%)
setPreference("IN", "hi_IN", 0.571) // Hindi
setPreference("IN", "en_IN", 0.106) // English
// Bosnia and Herzegovina
// https://en.wikipedia.org/wiki/Serbian_Cyrillic_alphabet
// Although the Bosnian language "officially accept[s] both alphabets", the Latin script is almost always used in the Federation of Bosnia and Herzegovina
setPreference("BA", "sr_BA_#Latn", 0.75) // Serbian
setPreference("BA", "sr_BA", 0.25) // Serbian
// Serbia
// https://en.wikipedia.org/wiki/Serbian_Cyrillic_alphabet
// Cyrillic is an important symbol of Serbian identity. In Serbia, official documents are printed in Cyrillic only even though, according to a 2014 survey, 47% of the Serbian population write in the Latin alphabet whereas 36% write in Cyrillic.
setPreference("RS", "sr_RS", 0.51) // Serbian
setPreference("RS", "sr_RS_#Latn", 0.5) // Serbian
// Belgium
// https://en.wikipedia.org/wiki/Languages_of_Belgium
// Dutch (1st language: ~55%, 2nd language: 16%)
// French (1st language: ~36%, 2nd language: ~49%)
setPreference("BE", "nl_BE", 0.55) // Dutch
setPreference("BE", "fr_BE", 0.36) // French
// Japan
setPreference("JP", "ja_JP", 0.51) // Japanese
setPreference("JP", "ja_JP_JP_#u-ca-japanese", 0.49) // Japanese
// Singapore
// https://en.wikipedia.org/wiki/Singapore#Languages
// Singapore has four official languages: English, Malay, Mandarin Chinese, and Tamil.[333] English is the common language, and is the language of business and government, and the medium of instruction in schools.
setPreference("SG", "en_SG", 0.369) // English
setPreference("SG", "zh_SG", 0.349) // Chinese
// Canada
// https://en.wikipedia.org/wiki/Languages_of_Canada
setPreference("CA", "fr_CA", 0.5597) // French
setPreference("CA", "en_CA", 0.2061) // English
// Switzerland
// https://en.wikipedia.org/wiki/Languages_of_Switzerland
// Year German French Italian Romansh Other
// 2015 63.0 22.7 8.4 0.6 5.3
setPreference("CH", "de_CH", 0.63) // German
setPreference("CH", "fr_CH", 0.227) // French
setPreference("CH", "it_CH", 0.084) // Italian
// Thailand
// https://docs.oracle.com/javase/tutorial/i18n/locale/extensions.html
// a Unicode locale extension is specified by the 'u' key code or the UNICODE_LOCALE_EXTENSION constant. The value itself is also specified by a key/type pair. Legal values are defined in the Key/Type Definitions table on the Unicode website. A key code is specified by two alphabetic characters.
// nu number type
setPreference("TH", "th_TH", 0.51) // Thai
setPreference("TH", "th_TH_TH_#u-nu-thai", 0.49) // Thai
// Luxembourg
// https://en.wikipedia.org/wiki/Languages_of_Luxembourg
// 2012 Luxembourgish French German English other
// Native language 52% 16% 2% N/A 30%
setPreference("LU", "fr_LU", 0.16) // French
setPreference("LU", "de_LU", 0.02) // German
// Montenegro
// https://en.wikipedia.org/wiki/Montenegrin_alphabet
// Although the Latin and Cyrillic alphabets enjoy equal status under the Constitution of Montenegro, the government and proponents of the Montenegrin language prefer to use the Latin script.
setPreference("ME", "sr_ME_#Latn", 0.8) // Serbian
setPreference("ME", "sr_ME", 0.2) // Serbian
// United States
setPreference("US", "en_US", 0.98) // English
setPreference("US", "es_US", 0.88) // Spanish
// Malta
// https://en.wikipedia.org/wiki/Languages_of_Malta
// 98% of Maltese people can speak Maltese, 88% can speak English
setPreference("MT", "mt_MT", 0.98) // Maltese
setPreference("MT", "en_MT", 0.88) // English
// Spain
// https://en.wikipedia.org/wiki/Languages_of_Spain
// the most prominent of the languages of Spain is Spanish (Castilian), spoken by about 99% of Spaniards as a first or second language.[5] Catalan (or Valencian) is spoken by 19%
setPreference("ES", "es_ES", 0.99) // Spanish
setPreference("ES", "ca_ES", 0.19) // Catalan
// Norway
// https://en.wikipedia.org/wiki/Languages_of_Switzerland
// Bokmål is the preferred written standard of Norwegian for 85% to 90%
// Nynorsk is reportedly used as main form of Norwegian by around 7.4% of the total population
setPreference("NO", "no_NO", 0.85) // Norwegian
setPreference("NO", "no_NO_NY", 0.074) // Norwegian
// Greece
// The official language of Greece is Greek, spoken by 99% of the population
// English (51%)
// German (9%)
// French (8.5%)
// Italian (8%)
setPreference("GR", "el_GR", 0.99) // Greek
setPreference("GR", "de_GR", 0.09) // German
更多信息: