Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommend way to create a custom culture and associated resource files for a specific Client?

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

like image 744
Justin Avatar asked Oct 08 '10 20:10

Justin


People also ask

What is RESX file in Visual Studio?

resx file contains a standard set of header information that describes the format of the resource entries, and specifies the versioning information for the XML code that parses the data. These files contain all the strings, labels, captions, and titles for all text in the three IBM Cognos Office components.

How do I add a resource to Visual Studio project?

In Visual Studio, open a SharePoint solution. In Solution Explorer, choose a SharePoint project node, and then, on the menu bar, choose Project > Add New Item. In the Add New Item dialog box, choose the Global Resources File template, and then choose the Add button.


1 Answers

public void AddCustomCulture(string cultureName, string baseCulture)
    {
        var cultureBuilder = new CultureAndRegionInfoBuilder(cultureName, CultureAndRegionModifiers.None);

        cultureBuilder.LoadDataFromCultureInfo(new CultureInfo(baseCulture));

        var region = baseCulture.Substring(3, 2);

        cultureBuilder.LoadDataFromRegionInfo(new RegionInfo(region));

        cultureBuilder.Register();
    }
like image 153
Owen Davies Avatar answered Nov 15 '22 19:11

Owen Davies