.NET 中的本地化地区/国家名称
是否可以在 .NET 中检索国家/地区的本地化名称?
RegionInfo 类 仅具有EnglishName、DisplayName 和 NativeName - 但似乎不可能获得“奥地利”的当地丹麦名称“Østrig”。 无论线程使用哪种 Culture 或 UICulture 运行,它们都将始终返回英文名称。
是否有我可以使用的技术,或者我必须为此创建一个数据存储?
Is it possible to retrieve a localized name of a country in .NET?
The RegionInfo class has only the EnglishName, DisplayName and NativeName - but it doesn't seem to be possible to get for example the local Danish name for "Austria" which is "Østrig". They will always return the English name, no matter which Culture or UICulture the thread runs with.
Is there a technique I can use, or will I have to create a data store for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅当框架具有所需语言的资源时,本地化名称才可用。 因此,您需要在 DisplayName 返回所需名称之前安装语言包(当然,在应用程序中设置正确的区域性)。
下载丹麦语 3.5 SP1 语言包这里(也可以选择许多其他语言)。
The localized names are only available if the framework has resources in the required language. Therefore, you need to install the language pack before DisplayName returns the wanted names (with the correct culture set in the application, of course).
Download the danish 3.5 SP1 language pack here (many other languages can be chosen as well).
各位,你们完全误解了MSDN的说法:
因此,您需要实现自己的国家/地区名称本地化。
Guys, you're completely misunderstood the MSDN statement:
So you need to implement your own localization for country names.
根据 MSDN 文档,
RegionInfo.DisplayName
应该获取该国家/地区的本地化名称(在您的情况下为丹麦语)。 鉴于它仍然为您返回英文版本,我怀疑您只需要在(重新)安装 .NET Framework 时配置区域设置。 让我知道这是否有效。According to the MSDN docs,
RegionInfo.DisplayName
should get the localised (in your case, Danish) name of the country. Given that it's still returning the English version for you, my suspicions are that you simply need to configure the locale when you (re)install the .NET Framework. Let me know if that does the trick.