我应该使用 ISO 3166 国家/地区代码 (US) 还是文化代码 (en-US)?

发布于 2024-08-09 07:36:50 字数 721 浏览 6 评论 0原文

ISO 3166 有一个包含 2 个字符的列表 国家/地区代码,例如美国英国法国

我使用的购物车既有这些代码,也有文化代码,例如 en-USen-UK

对于一个单独的项目,我认为较长的代码更有用,因为它至少告诉我该国家/地区使用的语言。但我似乎无法找到它们的准确列表。

我应该使用这些“文化代码”来跟踪国家/地区还是仅使用 2 个字符的 ISO 3166 名称?使用其中任何一个可能有什么问题?

我不确定为什么锁定英语的购物车会关心 en-US 与 US。有什么见解吗?

编辑: 另外,我在哪里可以获得文化代码列表?这是 ISO 标准吗?假设文化代码的国家/地区部分是 ISO 3166 国家/地区代码是否正确?

ISO 3166 has a list of 2 character country codes such as US, UK, FR.

A shopping cart I've used has both these codes and also the culture codes such as en-US or en-UK.

For a separate project I thought that the longer code is more useful because it at the very least tells me the language used by that country. But i cant seem to find an accurate list of them.

Should I use these 'culture codes' for tracking countries or just stick to the 2 character ISO 3166 names? What might be the catches of using either ?

I'm not sure why a shoppin cart that is locked to the english language would even care about en-US vs just US. Any insight?

Edit:
Also where can I get a culture code list? Is this an ISO standard? Is it correct to assume that the country portion of a culture code is an ISO 3166 country code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

聽兲甴掵 2024-08-16 07:36:51

正如一些人指出的那样,一个仅指示国家/地区 (US),而另一个指示语言和国家/地区 (en-US)。我只是想补充一点,拥有语言/国家的全部意义在于,这种关系不是一对一的。您可以在不同国家/地区使用同一种语言(pt-BR 与 pt-PT),也可以在同一国家/地区使用多种语言(fr-CA 和 en-CA)。

如果您需要跟踪的只是用户所在的国家/地区,请务必使用 ISO 代码。如果您需要跟踪文化和区域设置,那么我会使用完整的文化代码。

As a few have pointed out, one indicates only the country (US), while the other indicates both language and country (en-US). I just wanted to add that the whole point of having language/country is because this relationship is not one-to-one. You can have the same language spoken in different countries (pt-BR vs pt-PT), and you can have several languages spoken in the same country (fr-CA and en-CA).

If all you need to track is the user's country, by all means, use the ISO codes. If you need to track cultural and regional settings, then I'd use the full culture code.

审判长 2024-08-16 07:36:51

正如其他人所说,如果您想记录用户的地理位置,请使用 ISO 国家/地区代码。

如果您还想出于演示目的跟踪用户的文化(例如翻译、日期和数字格式),那么您应该存储两者。没有什么可以阻止居住在国外的用户使用他们的母语和文化设置。例如,居住在美国的讲法语的加拿大人可能拥有美国国家/地区代码,但需要 fr-CA 文化代码。

As others have said, if you want to record users' geographic location, then use the ISO country codes.

If you also want to track users' culture for presentation purposes (e.g. translations, date and number formatting), then you should store both. Nothing should prevent a user living abroad from using their native language and culture settings. For example a French-speaking Canadian living in the US might have the US country code but want the fr-CA culture code.

ゞ花落谁相伴 2024-08-16 07:36:50

国家代码用于识别国家。简直就是国家。

文化代码用于识别文化以引用其具体信息,例如小数点符号、日期分隔符、货币等。在这里,您对某个国家/地区不是直接感兴趣,而是对特定文化感兴趣。

如果您需要简单地跟踪国家/地区,请坚持使用 ISO 3166 代码。这是一个很好且简单的标准。如果您执行诸如 IP 到国家/地区确定之类的操作,那么大多数服务只会为您提供国家/地区,而不是特定的用户文化。

您确实需要告诉我们您想要的使用场景,然后才能提供更好的建议。

Country codes are used to identify countries. Simply countries.

Culture codes serve to identify cultures to refer to their specifics, like decimal signs, date separator, currencies etc. Here you are not directly interested in a country but in a particular culture.

If you need to simply track countries then stick with ISO 3166 codes. It is a good and simple standard. If you do something like IP-to-country determination, then most services will only give you countries but not specific user cultures.

You really need to tell us what usage scenario you have in mind, then it will be possible to advice better.

最佳男配角 2024-08-16 07:36:50

正如其他人指出的那样,这个问题的答案实际上取决于应用程序。

国家

国家是制定法律和管理法律管辖权的政治实体。各国定义了货币及其符号、贸易关税、电话号码前缀、度量衡系统(公制、英制等)等。国家/地区由 ISO 标准 3166 定义,该标准定义了一组两个字母 (alpha-2)、三个字母 (alpha-3) 和数字国家/地区代码。

ISO 3166-1 Alpha-2 代码与互联网 ccTLD 无关,尽管它们通常相同。

文化

文化是语言和社会规范的组合,定义了数字和日期的书写方式等事物。文化通常使用 ISO 639 语言代码来表示。每种语言实际上有四种不同的代码:alpha-2、alpha-3、基于英语语言名称的 alpha-3 以及带有方言扩展的 alpha-3。

国家和文化都与地理区域不完全相关。

在计算应用程序中

对于许多计算应用程序来说,了解这两者是很有用的。例如,您想知道以什么语言展示您的网站,并且您想知道用户希望使用什么货币进行购买、适用什么销售税、海关和邮政费率等等。

这就是熟悉的文化国家代码(例如 en-US)发挥作用的地方。这告诉您语言是英语(美国),国家/地区是美国。

美式英语与标准英语有不同的拼写,甚至不同的单词,这可能与您的应用程序相关,并且应使用英国数字符号。它还告诉您显示产品的货币是美元,符号是“$”并且货币有 100 个细分,您应该使用英制度量衡(英尺和磅),汽车部件必须用于左手开车,等等。

关于语言的说明

您无法自动按国家/地区采用语言。许多国家有不止一种官方语言。例如,在加拿大,它是英语和魁北克语(加拿大法语)。印度有 18 种官方语言,没有一种语言的人口超过 20% 左右。

As others have pointed out, the answer to this questions really depends on the application.

Countries

Countries are political entities which make laws and administer legal jurisdictions. Countries define things like currencies and their symbols, trade tariffs, phone number prefixes, systems of weights and measures (metric, imperial, etc) and so on. Countries are defined by ISO standard 3166, which defines a set of two-letter (alpha-2), three-letter (alpha-3) and numeric country codes.

The ISO 3166-1 Alpha-2 codes are unrelated to Internet ccTLDs, though they are often the same.

Cultures

Cultures are groupings of language and social norms defining things like the way numbers are written and dates are written. Cultures are usually denoted using their ISO 639 language codes. There are actually four different codes for each language, alpha-2, alpha-3, alpha-3 based on the English language name, and alpha-3 with dialect extensions.

Both countries and cultures are imperfectly correlated with geographic regions.

In computing applications

For many computing applications, it's useful to know both. For example, you want to know what language to present your website in, and you want to know what currency the user expects to make their purchases in, what sales tax to apply, customs and postal rates and so.

This is where the familiar culture-country codes, like en-US, come in. This tells you that the language is English (United States), and the country is USA.

American English has different spellings, and even different words, to standard English, which may be relevant to your application, and the British numerical notation should be used. It also tells you that the currency to display products in is USD, that the symbol is "$" and the currency has 100 subdivisions, that you should use imperial weights and measures (feet and pounds), car components must be for left-hand drive, and so on.

A note about language

You cannot automatically assume language by country. Many countries have more than one official language. For example, in Canada it's English and Quebecois (Canadian French). India has 18 official languages, and no one language is spoken by more than around 20% of the population.

落日海湾 2024-08-16 07:36:50

如果您只是跟踪用户所在的国家/地区,我会坚持使用国家/地区代码。文化更多的是用于跟踪小数点分隔符等内容(.,)。

If you're just tracking countries of your users, I would stick to the country codes. Culture is more for tracking things such as decimal separators (. vs ,).

咿呀咿呀哟 2024-08-16 07:36:50

我不是在回答您的主要问题,但英国的 ISO 3166 国家/地区代码是 GB,而不是 UK(不过,这是“特别保留的”),尽管后者是英国的 DNS TLD 代码(因为都市传说乔恩·波斯特尔的个人错误)。因此,“英式英语”的语言标签是 en-GB,而不是 en-UK。

话虽如此,目前还不清楚您需要这些代码的用途。

I'm not answering your main question, but the ISO 3166 country code for the United Kingdom is GB, not UK (which is “exceptionally reserved”, though), although the latter is the DNS TLD code for the United Kingdom (because of a personal error of Jon Postel, an urban legend has it). For that reason, the language tag for “British English” is en-GB, not en-UK.

That being said, it's not quite clear what you need those codes for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文