Registering custom languages

Sometimes there is the need of adding languages, which are not present yet. For example, if the customers have different versions of pages for english in the different countries.

You can add a language in /sitecore/system/Languages and just type in what you need. But this is not enough. You also have to register the language on your server.

Therefore we wrote a little console app. The idea was to have something we can just execute on every environmentand everything is fine.

First, we defined a json which holds the languages we want to add:

{
  "Cultures":
  [
    {
      "BaseFrom": "en-US",
      "BaseFromRegion": "US",
      "CultureName": "en-DE",
      "CultureLangTag": "en-DE",
      "CultureEnglishName": "English (Germany)",
      "NativeName": "Englisch (Deutschland)",
      "RegionEnglishName": "Germany",
      "RegionNativeName": "Deutschland",
      "LanguageCode": "en",
      "RegionCode": "DE",
      "SitecoreIconPath": "flags/16x16/flag_Germany.PNG"
    },
    {
      "BaseFrom": "en-US",
      "BaseFromRegion": "US",
      "CultureName": "en-AT",
      "CultureLangTag": "en-AT",
      "CultureEnglishName": "English (Austria)",
      "NativeName": "Englisch (Österreich)",
      "RegionEnglishName": "Austria",
      "RegionNativeName": "Österreich",
      "LanguageCode": "en",
      "RegionCode": "AT",
      "SitecoreIconPath": "flags/16x16/flag_Austria.PNG"
    }
  ]
}

In the app.config we define the path to the json File and the path of the LanguageDefinitions.config in the web, where we want to add the language.

<appSettings>
    <add key="JsonPath" value="C:\\Projects\\SitecoreCustomLanguages\\SitecoreCustomLanguages\\RegisterLanguages\\App_Data\\CultureDefinitions.json"/>
    <add key="ConfigPath" value="C:\\inetpub\\wwwroot\\local.sc92.de\\App_Config\\LanguageDefinitions.config"/>
  </appSettings>

So, what the program does, is the following. For every language which is defined in the json File it checks, whether the language is already registered and only if not the language is registered and added in the LanguageDefinitions.config.

You can find the code here: https://github.com/anbrue/SitecoreCustomLanguages

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.