6

I tried adding custom lang-region set in /sitecore/system/Languages but got following error message:

Language: pt and Region: mx

Language: en and Region: mx

Language: es and Region: br

The name "{Language}-{Region}" is not a valid or supported culture identifier.

Basically we are going to set up Sitecore website with 13 regions and each region should support 3 languages (en, es, pt) so I have to add 39 languages in system/languages.

Example:

en-mx, es-mx, pt-mx

es-br, es-br, pt-br

en-cl, es-cl, es-br

and so on till 39th Language

1
  • I was reading it again and thought do you actually need languages for regions that dont have certain languages? using your example es-br, pt-br, es-br.There are two portuguese languages(Brazil and Portugal). Using es-br assumes that site in Brazil for example should have a spanish version. Doesnt it make sense to think in terms of languages and set which version should have a default language? In this example Brazil would have pt-br. If you want to see the spanish version just change it to es-ES for example.
    – Diego
    Commented Feb 9, 2017 at 16:08

2 Answers 2

7

You need to follow next steps:

  1. Download Language Registration tool from https://marketplace.sitecore.net/en/Modules/Custom_Language_Registration.aspx
  2. Start the “Language Registration” tool
  3. Change the name to “pt-MX”
  4. Click the “Register” button
  5. Declare a new language in the “\App_Config\LanguageDefinitions.config” file:

//Example

 <language id="pt" region="MX" codepage="65001" encoding="utf-8" charset="iso-XXXX" icon="flags/16x16/flag_Mexic.PNG" />
  1. Start Sitecore
  2. Open the “Add a new Language” dialog
  3. Select the required language from the “Predefined Languages” list
  4. Click “Next” until dialog is closed

Other links :

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

https://mwenhao.wordpress.com/2014/11/05/how-to-register-custom-language-and-culture-into-sitecore-and-net/

http://www.nttdatasitecore.com/Blog/2016/September/Adding-Custom-Language-in-Sitecore

9
  • I would add that this registration needs to happen on every machine that's using this language (each box in each environment). You'll got problems if you forget to run the registration application on one of the delivery servers for example. Commented Feb 9, 2017 at 10:11
  • Yes you are right Commented Feb 9, 2017 at 10:16
  • Along side with registering it you need to register the language on the Windows otherwise you may have issues in the future like this one: sitecorebrasil.wordpress.com/2017/01/25/…
    – Diego
    Commented Feb 9, 2017 at 14:14
  • I tried to install this in sitecore but it's continuously spinning...does it compatible with Sitecore 8.1
    – Sukhjeevan
    Commented Feb 9, 2017 at 16:51
  • What did you try to install in Sitecore? Commented Feb 9, 2017 at 16:53
3

This is how I approached custom languages.

  • Register your custom language in .net.
  • Add custom language to /AppConfig/LangauageDefinitions.config
  • Add your custom language item in sitecore/system/Languages, u should see your custom culture info in "Choose a predefined language code" dropdown now.

Step1:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(SitecoreBlog.SitecoreCustom.Globalization.Language.RegisterLanguages), "Register")]
namespace SitecoreBlog.SitecoreCustom.Globalization.Language
{
public class RegisterLanguages
{
    private class CustomCulture
    {
        public CustomCulture(string isoName, string fromCulture, string displayName)
        {
            IsoName = isoName;
            FromCulture = fromCulture;
            DisplayName = displayName;
        }

        public string IsoName { get; set; }
        public string FromCulture { get; set; }
        public string DisplayName { get; set; }
    }

    /// <summary>
    /// Registers the custom languages required by the solution
    /// </summary>
    /// <remarks>
    /// When this code runs it will need the following permissions on the host system:
    /// - modify rights to "C:\Windows\Globalization" as it needs to create the .nlp file for the custom culture
    /// - full control rights to the "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CustomLocale" registry path as it needs to the corresponding entry for the custom culture
    /// 
    /// If these fail then you will get an exception. If you resolve the issue and retry then the OS can get confused as the .nlp file may exist but the registery key doesn't.
    /// In this situation you will need to remove the .nlp and/or the registry key so the code can start from stratch.
    /// 
    /// Once this has been run successfully, you will find that the language will appear in the list of predefined languages in Sitecore.
    /// </remarks>
    public static void Register()
    {
        //if you add new custom cultures, you need to add that in /AppConfig/LangauageDefinitions.config
        var customCultures = new List<CustomCulture>() {
            new CustomCulture("pt-mx", "fromCulture", "Protugese (Mexico)"),
            new CustomCulture("en-mx", "fromCulture", "English (Mexico)")
            //etc

        };

        var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

        try
        {
            foreach (var customCulture in customCultures)
            {
                if (!allCultures.Any(culture => string.Equals(culture.Name, customCulture.IsoName, StringComparison.CurrentCultureIgnoreCase)))
                {
                    var cib = new CultureAndRegionInfoBuilder(customCulture.IsoName, CultureAndRegionModifiers.None);
                    cib.LoadDataFromCultureInfo(new CultureInfo(customCulture.FromCulture));
                    cib.LoadDataFromRegionInfo(new RegionInfo(customCulture.FromCulture));
                    cib.CultureEnglishName = customCulture.DisplayName;
                    cib.CultureNativeName = customCulture.DisplayName;
                    cib.RegionEnglishName = customCulture.DisplayName;
                    cib.RegionNativeName = customCulture.DisplayName;

                    cib.Register();
                }
            }
        }
        catch (Exception e)
        {
            throw new Exception(@"Unable to register custom locales. Check app pool has modify rights to C:\Windows\Globalization directory and full control rights to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CustomLocale registry path.", e);
        }
    }
}

}

Make sure you have given right permissions. see comments for which folders.

Step2:

Add a patch file like below:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <languageDefinitions>
      <languages>
        <language id="pt" region="mx" codepage="65001" encoding="utf-8" charset="iso-8859-1" icon="flags/16x16/XXX.PNG" />
        <language id="en" region="mx" codepage="65001" encoding="utf-8" charset="iso-8859-1" icon="flags/16x16/XXX.PNG" />
      </languages>
    </languageDefinitions>
  </sitecore>
</configuration>
1
  • 2
    why is this down voted, at least comment whats wrong, so i can edit? Commented Feb 9, 2017 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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