每个国家/地区的 CultureInfo 名称
我有一个国家/地区列表,其中包含两个字母代码(例如“美国”)和三个字母代码(例如“美国”)。 我只想指定所有 239 个国家/地区都有区域设置代码,例如 en-US(而不是 es-US)。
我尝试了迭代:
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
然后:
var country = countries.Where(c => c.CodeIso3 == region.ThreeLetterISORegionName).FirstOrDefault();
它不起作用,太多的覆盖。
如何将 239 个国家/地区代码分配给主要(或默认)语言?
谢谢
I have country list with two letter code like 'US' and and three letter code like 'USA'.
I just want to assign all 239 countries have the locale code like en-US (not es-US).
I tried the iterate on:
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
then:
var country = countries.Where(c => c.CodeIso3 == region.ThreeLetterISORegionName).FirstOrDefault();
it doesnt work, to much override.
how to assign the 239 countries code to with is major(or default) language?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有办法做到这一点。这是因为您想到的许多国家/地区都没有默认语言之类的东西。
例如,美国没有官方语言。尽管大多数公民都使用英语,但它并不是默认的。另一个有趣的例子是瑞士。其公民使用法语、德语、意大利语和罗曼什语。这些都不是默认的。
这就是为什么没有这样的 API 的原因。
编辑:
正如我之前所说,在许多国家/地区没有默认语言。我什至举了一个拥有不止一种主要语言(德语和法语)的国家的例子。对于仍然无法理解这确实没有意义的所有人,我将向您提供如何猜测最可能的语言的线索:
通用区域设置数据存储库区域语言信息
如果您仍然不明白为什么要限制每个国家使用一种语言可能不是最好的主意,我放弃了。
There is no way to do that. That is because there is no such thing as default language for many of the countries you have in mind.
For example, US does not have an official language. Although English is used by majority of its citizens, it is not default. The other interesting example would be Switzerland. Its citizens use French, German, Italian and Romansh. None of these is default.
That is the reason why there is no such API.
Edit:
As I said before, in many countries there is no such think as default language. I even gave an example of the country which has more than one major language (German and French). To all of you that still can't understand that this really does not make sense, I will give you a clue on how to guess the most probable language:
Common Locale Data Repository Territory-Language Information
If you still cannot understand why restricting to one language per country is probably not the best of ideas, I give up.