本文介绍了什么是推荐的方法来创建一个自定义的文化和相关的资源文件为特定客户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有希望specifiy自己本地化内容的版本为我串的资源子集的客户端

I have client that wants to specifiy their own version of localized content for a subset of my string resources.

为了简单起见这里是基本的例子:结果
可以说我有2本地化的字符串(英文显示的内容)
结果的PageTitle =Hello World的
结果PageDescription =这是世界您好更罗嗦的版本!

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的(包含我的英语水平
    字符串)

  • Strings.fr-ca.resx
    (包含我的加拿大法语字符串)

  • Strings.fr-CA-clientX.resx的(含
    我的琴弦的客户是谁
    加拿大法语和therfore非常
    挑剔) - 只是在开玩笑)

  • Strings.resx (contains my Englishstring)
  • Strings.fr-ca.resx(contains my French-Canadian strings)
  • Strings.fr-ca-clientX.resx (containsmy strings for a Client whom isFrench-Canadian and therfore verypicky;) - just joking)

在理想情况下Strings.fr-CA-clientX只能指定他们要覆盖的字符串。换句话说,他们可能只是希望改变的PageTitle并继续使用PageDescription从FR-CA资源文件。

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.

那么,如何去了解这个在.NET?理想情况下,我只想创建的resx文件,并在我的web.config指定的文化,它应该工作...

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" />

但是,这是行不通的。 标签包含了文化属性的值无效是我的第一obsticle。

However, this does not work. "The tag contains an invalid value for the 'culture' attribute" is my first obsticle.

谢谢,
结果贾斯汀

Thanks,
Justin

推荐答案

您可以创建一个新的文化具有以下code:

You can create a new culture with the following code:

        //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();

我已经写了一个帖子上创建一个应用程序来做到这一点。

I have written a post on creating an app to do just that..

这篇关于什么是推荐的方法来创建一个自定义的文化和相关的资源文件为特定客户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:21