具有单例模式的 .resx 文件(特定于文化)?
老实说,这是我第一次接触 resx 文件。我尝试调查什么是不好的和好的做法,发现有很多想法和台词可供很快有人翻译。
总的来说,我进入了这个想法,
- 根据需要创建所有“Resources/Purpose.lang-COUNTRY.resx”
- 创建一个加载 currentculture 的单例并挂钩相应的 resx 文件。
只要需要,就使用 SingletonName.GetString("StringVariable");
- 这里使用 Singleton 怎么样?
- 是/否,什么是更好的做法?
我也对如何找到正确的名称来引用嵌入的 resx 感到有点困惑。
ResourceManager rm =
new ResourceManager("SomeLang.en-US", Assembly.GetExecutingAssembly());
它搜索.resource(文件名为resx),但我无法通过反射器在dll中找到资源规范。
Honestly this is first time into resx files for me. I try to investigate what bad and good practice and finds that there exist as much ideas as lines for someone soon to translate.
As whole I got into this idea,
- Create all "Resources/Purpose.lang-COUNTRY.resx" as needed
- Create a singleton that loads currentculture and hook corresponding resx file.
Whenever needed, use SingletonName.GetString("StringVariable");
- How about using Singleton here?
- Yes/no what's better practice?
I'm also a little confused of how to find correct name to refer the embedded resx.
ResourceManager rm =
new ResourceManager("SomeLang.en-US", Assembly.GetExecutingAssembly());
It searches for a .resource (the files are named resx) and I can't find the resource specification in dll through reflector..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 ASP.NET MVC3 中发现了一种相当直接的国际化方法,我认为这可能会给您一个不同的角度来考虑/比较当前的方法。
http://afana.me/post/aspnet-mvc-internationalization.aspx
I found a fairly straight forward approach for internationalization in ASP.NET MVC3 that I thought may give you a different angle to consider / compare your current approach with.
http://afana.me/post/aspnet-mvc-internationalization.aspx