Tags: CMS12 Optimizely CMS

Problem with language file localization after upgrading to Optimizely CMS 12

The documentation for Optimizely CMS describes how to «Localize the user interface», and has an example with embedded localization like this.

services.AddEmbeddedLocalization<Startup>();

The documentation also states the following.

You can give the language file any name and have each language in a separate file (or in one file).

In my experience, this is not entirely true!

Upgrading to CMS 12

In most solutions I have upgraded, the language files are named like this, with an extra period in addition to the period right before the xml file extension.

/LanguageFiles/
    - Site.EN.xml
    - Site.NO.xml 

The extra period needs to be removed in order for this to work. You can give the files any name, as long as it does not have more than one period.

Steps required when upgrading from CMS 11 to CMS 12

Step 1: Remove additional periods

Rename the files like this.

/LanguageFiles/
    - SiteEN.xml
    - SiteNO.xml 

Step 2: Embedd language files

Embed the files one by one, or the entire directory by adding this to the project file.

<ItemGroup>
    <EmbeddedResource Include="LanguageFiles\**\*" />
</ItemGroup>

Step 3: Add localization provider

Add this to startup.cs.

services.AddEmbeddedLocalization<Startup>();

That's it!

Found this post helpful? Help keep this blog ad-free by buying me a coffee! ☕