为特定客户创建自定义区域性和关联资源文件的推荐方法是什么?
我的客户想要为我的字符串资源子集指定他们自己的本地化内容版本。
为简单起见,这里是基本示例:
假设我有 2 个本地化字符串(显示英文内容)
PageTitle="你好世界"
PageDescription="这是 Hello World 的更冗长的版本!"
我希望本地化这些,以便我有资源文件。
- Strings.resx (包含我的英语 字符串)
- Strings.fr-ca.resx (包含我的法语-加拿大字符串)
- Strings.fr-ca-clientX.resx (包含 我的客户字符串是 法裔加拿大人,因此非常 挑剔;) - 只是开玩笑)
理想情况下,“Strings.fr-ca-clientX”只能指定他们想要“覆盖”的字符串。换句话说,他们可能只想更改 PageTitle 并继续使用“fr-ca”资源文件中的 PageDescription。
那么我该如何在 .NET 中解决这个问题呢?理想情况下,我只需创建 resx 文件并在“Web.config”中指定区域性,它应该可以工作......
<globalization uiCulture="fr-ca-clientX" culture="fr-ca-clientX" />
但是,这不起作用。 “标签包含无效的‘文化’属性值”是我的第一个障碍。
谢谢,
贾斯汀
I have client that wants to specifiy their own version of localized content for a subset of my string resources.
For simplicity here is basic example:
Lets say I have 2 localized strings (showing english content)
PageTitle="Hello World"
PageDescription="This is a more wordy version of Hello World!"
I wish to localize these so I have resource files.
- Strings.resx (contains my English
string) - Strings.fr-ca.resx
(contains my French-Canadian strings) - Strings.fr-ca-clientX.resx (contains
my strings for a Client whom is
French-Canadian and therfore very
picky;) - just joking)
Ideally "Strings.fr-ca-clientX" can specify only the strings they want to "override". In other words they may just wish to change the PageTitle and continue using the PageDescription from the "fr-ca" resource file.
So how do I go about this in .NET? Ideally I would just create the resx file and specify the culture in my "Web.config" and it should work...
<globalization uiCulture="fr-ca-clientX" culture="fr-ca-clientX" />
However, this does not work. "The tag contains an invalid value for the 'culture' attribute" is my first obsticle.
Thanks,
Justin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下代码创建一种新的文化:
我已经写了一篇关于创建应用程序来执行此操作的帖子..
http://wraithnath.blogspot.com/search/label/Globalization
You can create a new culture with the following code:
I have written a post on creating an app to do just that..
http://wraithnath.blogspot.com/search/label/Globalization
您可能需要创建自己的文化并注册它。您可以在此处找到有关该主题的 MSDN 文章。
您不需要更改区域性属性,它应该保留在“fr-CA”,因为 uiCulture 属性负责从资源加载字符串。
You probably need to create your own culture and register it. You'll find MSDN article on that topic here.
You don't need to alter culture attribute, it should stay at "fr-CA", as uiCulture attribute is responsible for loading strings from resources.