5

I got a request from one of our international content owners where they wanted a site in anglicized English but for a country that does not have a pre-set for English.

In this case it would be an anglicized English site for Saudi Arabia - en-SA. When I choose the the Add a new language option, I specify the language en and the country SA but I am then confronted with the error:

The name "en-SA" is not a valid or supported culture identifier.

Do I need to do this another way or is it just not possible? I've never had to do this, but it seems that this is exactly why the option to specify a language and country is an option of this dialogue.

4

This is a limitation of ASP.NET, which is what Sitecore uses.

You need code to register new culture/language combinations.

Sitecore Marketplace module that will help you: https://marketplace.sitecore.net/en/Modules/Custom_Language_Registration.aspx

You'll need to remember to install the custom language on each machine running Sitecore (every CM and CD in development and production).

Demonstration of module: http://www.bugdebugzone.com/2013/12/adding-custom-language-code-in-sitecore.html

Code wise, if you don't want to install a module (tool) for this, here's a snippet that does the same thing.

private static void RegisterCulture(string cultureCode, string cultureName, string baseCultureCode)
{
    var ci = new CultureInfo(baseCultureCode);
    var ri = new RegionInfo(ci.Name);
    var builder = new CultureAndRegionInfoBuilder(cultureCode, CultureAndRegionModifiers.None);
    builder.LoadDataFromCultureInfo(ci);
    builder.LoadDataFromRegionInfo(ri);

    builder.CultureEnglishName = cultureName;
    builder.CultureNativeName = cultureName;

    try
    {
        builder.Register();
    }
    catch (InvalidOperationException)
    {

    }
}

Sourced from here: https://stackoverflow.com/questions/15336263/asp-net-mvc-registering-custom-culture-and-internationalization

  • 1
    Worth noting that this is machine specific so you'll need this code to run on every instance running Sitecore which needs access to this custom language. Also, having used this tool in anger (unless it's been improved) it can be a little fiddly and takes a little getting used to. – Owen Niblock Nov 8 '16 at 20:43
  • Right. Yep. It's registered on machine level. And only needs to be run once per machine. – Mark Cassidy Nov 8 '16 at 20:44
  • This is very helpful. Our infrastructure team uses geo-location to send first time visitors to what their locale indicates they may prefer language-wise. Of course, the visitor can always choose whatever language-region they prefer. – Sirius_B Nov 8 '16 at 21:04
  • I guess I am a little disappointed that this is as complex to implement since I can easily see why you might want different language options per region outside of what is predefined. I'll mark this as accepted since if we move forward, it would be the approach we would take and will add a comment if we go with the implementation to provide insight into how well it worked. – Sirius_B Nov 8 '16 at 21:08
  • 1
    It is annoying, but I've had to deal with it before. That said; it might be worthwhile digging into the root reasons your content people want this option. I've been on projects that had 22 variations of "en" language (en-DE, en-IT, en-FR and so on) simply to do regionalised content promotion. Sitecore has other means to achieve this end. – Mark Cassidy Nov 8 '16 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.