我有客户想要为我的字符串资源的一部分指定自己的本地化内容版本。
为了简单起见,这里是基本的例子:
说我有2个本地化的字符串(显示英文内容)
PageTitle =“Hello World”
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" />
但是,这不行。 “标签包含”文化“属性的无效值”是我的第一个结论。
谢谢,
贾斯汀
解决方法
您可以使用以下代码创建新文化:
//Get culture info based on Great Britain CultureInfo cultureInfo = new CultureInfo( "en-GB" ); regioninfo regioninfo = new regioninfo( cultureInfo.Name ); CultureAndregioninfoBuilder cultureAndregioninfoBuilder = new CultureAndregioninfoBuilder( txtCultureName.Text,CultureAndRegionModifiers.None ); cultureAndregioninfoBuilder.LoadDataFromCultureInfo( cultureInfo ); cultureAndregioninfoBuilder.LoadDataFromregioninfo( regioninfo ); // Custom Changes cultureAndregioninfoBuilder.CultureEnglishName = txtCultureName.Text; cultureAndregioninfoBuilder.CultureNativeName = txtNativeName.Text; cultureAndregioninfoBuilder.Register();
我写了一篇关于创建应用程序的帖子。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。