ben.morris@fortunecookie.co.uk
Oct 2, 2009
  11621
(0 votes)

Adding new languages to EPiServer 5

We’ve recently run into problems with adding the less commonly-used language and locale combinations on an EPiServer installation. How do you add a new language to EPiServer 5 if it doesn’t appear in the list of available languages?

EPiServer takes the list of the languages that you can enable for a site from the languages that are installed on the host operating system. This can be a problem as the available languages can vary between different machines - for example, Indian English (en-IN) is shipped with Vista but not with Windows 2003 or XP. The big catch is that if you have a language enabled in your EPiServer database which is not installed on your target machine then EPiServer will throw an exception on start-up, which will pull your whole site down.

If you want to add a new language to EPiServer then you will have to install it on your operating system. This can be done via the CultureAndRegionInfoBuilder class in System.Globalization. This class allows you to create a new language from scratch or by copying it from an existing language, although you will have to run the code in the context of an Administrator account for it to work.

The code sample below shows how CultureAndRegionInfoBuilder can be used to create and register a new language based upon an existing language – in this case creating Hong Kong English (en-HK) from UK English (en-GB). Note that you’ll need a reference to sysglobl.dll in your project for this to compile.

public static void CreateCulture()
{
    //* Get the base culture and region information
    CultureInfo cultureInfo = new CultureInfo("en-GB");
    RegionInfo regionInfo = new RegionInfo(cultureInfo.Name);

    //* Create the a locale for en-HK
    CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = new CultureAndRegionInfoBuilder("en-HK", CultureAndRegionModifiers.None);

    //* Load the base culture and region information
    cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(cultureInfo);
    cultureAndRegionInfoBuilder.LoadDataFromRegionInfo(regionInfo);

    //* Set the culture name
    cultureAndRegionInfoBuilder.CultureEnglishName = "English (Hong Kong)";
    cultureAndRegionInfoBuilder.CultureNativeName = "English (Hong Kong)";

    //* Register with your operating system
    cultureAndRegionInfoBuilder.Register();

}

Once you’ve run this code, fire up EPiServer in Admin mode, select Manage Web Site languages from the Config tab, click on Add Language and your new locale will be ready to use.

Oct 02, 2009

Comments

Renu Rathor
Renu Rathor Sep 21, 2010 10:32 AM

I am trying to apply these changes, but it doesnt tell me where di i need to add this method, any step by atep complete process to get it working?

Sep 21, 2010 10:32 AM

Renu, you can simply create a command line application that will create and register the language for you. This only needs to be done once on each machine.

Renu Rathor
Renu Rathor Sep 21, 2010 10:32 AM

I want to edit the language culture appera in drop down of Regional and language culture, how can i do that?

paul.graham@fortunecookie.co.uk
paul.graham@fortunecookie.co.uk Sep 21, 2010 10:32 AM

Once a new culture has been create you'll it'll appear here C:\Windows\Globalization
as *.nlp file you can then copy the between servers.

Jon Haakon Ariansen
Jon Haakon Ariansen Nov 24, 2010 09:29 AM

I'm about to create a new language. I have explored the code and found the directory "Globalization" on my client machine, but I can't find "c:\windows\Globalization" on Windows 2003?
Could it be that the server needs windows update? Is "c:\windows\globalization" part of Framework 4?
If I need windows update, anybody who knows which "patch" I need to run to install this on Windows 2003?

Kind regards,
Jon Haakon

Jon Haakon Ariansen
Jon Haakon Ariansen Nov 24, 2010 12:42 PM

I'm about to create a new language. I have explored the code and found the directory "Globalization" on my client machine, but I can't find "c:\windows\Globalization" on Windows 2003?
Could it be that the server needs windows update? Is "c:\windows\globalization" part of Framework 4?
If I need windows update, anybody who knows which "patch" I need to run to install this on Windows 2003?

Kind regards,
Jon Haakon

paul.graham@fortunecookie.co.uk
paul.graham@fortunecookie.co.uk Jun 29, 2012 12:40 PM

once you've excuted the CreateCulture the c:\windows\Globalization will magically appear.

Please login to comment.
Latest blogs
Increase timeout for long running SQL queries using SQL addon

Learn how to increase the timeout for long running SQL queries using the SQL addon.

Tomas Hensrud Gulla | Dec 20, 2024 | Syndicated blog

Overriding the help text for the Name property in Optimizely CMS

I recently received a question about how to override the Help text for the built-in Name property in Optimizely CMS, so I decided to document my...

Tomas Hensrud Gulla | Dec 20, 2024 | Syndicated blog

Resize Images on the Fly with Optimizely DXP's New CDN Feature

With the latest release, you can now resize images on demand using the Content Delivery Network (CDN). This means no more storing multiple versions...

Satata Satez | Dec 19, 2024

Simplify Optimizely CMS Configuration with JSON Schema

Optimizely CMS is a powerful and versatile platform for content management, offering extensive configuration options that allow developers to...

Hieu Nguyen | Dec 19, 2024

Useful Optimizely CMS Web Components

A list of useful Optimizely CMS components that can be used in add-ons.

Bartosz Sekula | Dec 18, 2024 | Syndicated blog

SaaS CMS - Pages and Blocks get the Visual Builder Treatment

I’m thrilled to see that Optimizely has now enabled Visual Builder for OG Pages and Blocks within SaaS CMS, and I’m guessing this will become...

Minesh Shah (Netcel) | Dec 17, 2024