如何从Java Locale获取一个国家的官方名称?

huangapple go评论79阅读模式
英文:

How to get a country's official name from a Java Locale?

问题

在ISO-3166中,涉及国家时,“短名称”和“完整名称”之间存在差异。

例如,丹麦(链接至iso.org参考:https://www.iso.org/obp/ui/#iso:code:3166:DK)。
其国家代码将为DK和DNK(alpha-2和alpha-3),其数字代码为208,其短名称为'丹麦',其完整名称为'丹麦王国'。

对于我的当前项目,我已经拥有了所需的所有信息,除了完整名称。

是否有人知道获取这种数据的方法?

英文:

In ISO-3166, when it comes to the country, there is a difference between "short name" and "full name".

For example, Denmark (link to iso.org reference : https://www.iso.org/obp/ui/#iso:code:3166:DK).
Its country code would be DK and DNK (alpha-2 and alpha-3), its numeric code is 208, its short name is 'Denmark', and its full name is 'the Kingdom of Denmark'.

For my current project, I have all the information I need except full name.

Does anyone know of a way to get that kind of data?

答案1

得分: 1

Java的内置本地化不支持官方的国家名称。

以下是丹麦的条目在本地化数据中的内容:

DK=丹麦

你可以使用类似于https://restcountries.eu/的REST API,或者我找到了这个CSV文件,它似乎包含了你需要的内容。你需要解析它。

英文:

Java's in-built localization doesn't support official country names.

Here's the entry for Denmark in the localization data

DK=Denmark

You can use a REST API like https://restcountries.eu/, or I found this CSV file which seems to contain what you want. You will need to parse it.

huangapple
  • 本文由 发表于 2020年9月3日 19:20:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/63722583.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定