资源文件和卫星程序集
由于缺乏更好的词,我是本地化和资源文件的新手。 我正在尝试本地化我正在开发的应用程序,并且想使用资源文件和附属程序集来完成此操作,但我不知道如何正确执行此操作。 到目前为止,这是我所拥有的:
在我的项目目录中:我创建了文件 LanguageText.resx 和 LanguageText.nl.resx
在我的项目/bin 目录中:我创建了文件夹“nl”
在我的项目/bin/nl 目录中:我使用ResGen.exe从LanguageText.nl.resx文件创建LanguageText.nl.resources文件,然后我使用AL.exe创建project.resources.dll文件。 该 .dll 文件位于 bin/nl 文件夹中。 它组装正常,现在我的 project/bin/debug 文件夹中也有 nl/project.resources.dll 。
我的问题是,我的程序中显然没有嵌入中性语言文件或资源,但我找不到任何有关如何执行此操作的信息。 我能找到的关于以这种方式嵌入资源的唯一信息与卫星程序集有关。 如何嵌入中性语言资源?
任何帮助或指导表示赞赏。
谢谢, 麦克风
I am, for lack of a better word, a newbie to Localization and resource files. I am trying to localize an application I am working on and I want to do it using resource files and satellite assemblies, but I can't figure out how to do it correctly. Here is what I have so far:
In my project directory: I created the files LanguageText.resx and LanguageText.nl.resx
In my project/bin directory: I created the folder "nl"
In my project/bin/nl directory: I used ResGen.exe to create LanguageText.nl.resources file from LanguageText.nl.resx file, then I used AL.exe to create the project.resources.dll file. That .dll file is in the bin/nl folder. It assembled ok and now I have nl/project.resources.dll in my project/bin/debug folder as well.
My problem is that I apparently do not have a neutral language file or resource embedded in my program, but I can't find any info on how to do that. The only info I can find about embedding resources in this manner is related to satellite assemblies. How do I embed the neutral language resource?
Any help or direction is appreciated.
Thanks,
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 AssemblyInfo 的帮助下完成此操作。 转到 AssemblyInfo.cs 并添加属性
确保在顶部添加 using 语句
using System.Resources;
。 上面的行表明程序集的中性资源语言是“en-US”,这是一个卫星程序集。You can do it with the help of AssemblyInfo. Go to AssemblyInfo.cs and add the attribute
Make sure to add using statement
using System.Resources;
at the top. The above line indicates that the neutral resource language of your assembly is 'en-US' and this is a Satellite assembly.后备资源应放置在 bin 文件夹中的 LanguageText.dll 中。
或者,您可以将 System.Resources.NeutralResourcesLanguageAttribute 属性添加到 LanguageText.dll 程序集中,
并指定在区域性不变或给定区域性不匹配的情况下使用的默认区域性。
生成 nl 程序集,将其命名为 LanguageText.resources.dll,放置在 bin/nl 文件夹中。
通过在线程上设置区域性并使用 ResourceManager 检索资源来验证这是否有效。
The fallback resources should be placed in LanguageText.dll in the bin folder.
Alternatively, you may add an System.Resources.NeutralResourcesLanguageAttribute attribute to the LanguageText.dll assembly,
and specify a default culture used if the culture is invariant, or there is no match for a given culture.
Generate the nl assembly, call it LanguageText.resources.dll, place in bin/nl folder.
Verify that this works, by setting the culture on your thread and use a ResourceManager to retrieve resources.