.net resx 文件和本地化

发布于 2025-01-03 02:26:25 字数 411 浏览 3 评论 0原文

我想我明白了,但有几个方面让我感到困惑。假设我想要为德国、西班牙和美国的 MyApp 本地化字符串。

MyApp.resx
MyApp.de-DE.resx
MyApp.es-ES.resx
MyApp.en-US.resx // this *feels* redundant

由于我是一名美国开发人员,最后一个 rex 文件(“en”)将具有与“中性”文件相同的键和值,但是......我需要两者吗?

我可以猜测答案,但尽管(或者可能是因为)所有 msdn 文档都解释了最终回退、卫星和中性语言,但它似乎令人困惑。

有国际发展经验的人能否以(非常)简单的方式解释原因或原因?如果我正在开发 WPF、Silverlight、ASP 或其他 .Net 变体,这会重要吗?

干杯,
贝里尔

I think I get it, but a couple of aspects are confusing me. Say I want strings localized for MyApp in Germany, Spain and the USA.

MyApp.resx
MyApp.de-DE.resx
MyApp.es-ES.resx
MyApp.en-US.resx // this *feels* redundant

The last rex file ("en") will have the same keys and values as the "neutral" one since I am an American developer, but ... do I need both?

I can guess at the answers but it seems confusing despite, or maybe because of, all the msdn docs explaining the ultimatefallback, satellites, and neutral language.

Can someone experienced with international development explain why or why not in a (really) simple manner? And would it matter if I were doing WPF, Silverlight, ASP or some other .Net variation?

Cheers,
Berryl

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

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

发布评论

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

评论(2

俏︾媚 2025-01-10 02:26:25

如果主程序集 (MyApp.resx) 中的资源采用 en-US 区域性,则无需创建 MyApp.en-US.resx 文件。如果没有找到该区域性的附属程序集,资源管理器将回退到主程序集中的资源。

If the resources in the main assembly (MyApp.resx) are in the en-US culture, you don't need to create a MyApp.en-US.resx file. If no satellite assembly is found for this culture, the resource manager will fall back to the resources in the main assembly.

追我者格杀勿论 2025-01-10 02:26:25

同意托马斯的观点。如果您的应用程序的主要语言是 en-us,那么您只需将所有字符串放在主资源中,并将该字符串的所有翻译(例如德语、法语等)放在相应的卫星资源文件中。

例如 - 主要语言是 En-Us,但您还想支持英国语、德语、西班牙语。因此,您将所有原始字符串放入默认资源文件中,例如Resources.resx。然后创建 Resources.en-GB.resx、Resources.de-De.resx、Resources.es-ES.resx 并将原始字符串的翻译放置在其中。

如果美国和英国版本的某些字符串相同,您只需从 Resources.en-GB.resx 文件中删除这些字符串即可。因为将检查第一个附属程序集的资源,如果尚未找到资源字符串,则将使用该字符串的主程序集版本。

Agreed with Thomas. If main language for your application is en-us than you just place all your strings in main resources and all translations of this strings(such as German, French etc) at corresponding satellite resource files.

For example - main language is En-Us, but u also want to support british, german, spanish. So you place all original strings in default resource file, say Resources.resx. Then you create Resources.en-GB.resx, Resources.de-De.resx, Resources.es-ES.resx and place there translations of original strings.

If some of the strings are equal for american and british versions, you just delete this strings from Resources.en-GB.resx file. Because first satellite assembly will be examined for resource, and if resource string hasn't been found - main assembly version of this string will be used.

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