Welcome to the navigation

Pariatur, ut adipisicing non sunt qui ex cillum esse ad eu ea sint ut voluptate cupidatat nostrud labore dolor laborum, consequat, enim dolor lorem officia. Consequat, dolor dolor labore lorem ullamco ex exercitation eiusmod sed veniam, ea officia laboris excepteur cillum enim ad qui aliqua, voluptate ut quis in commodo

Yeah, this will be replaced... But please enjoy the search!

Implementing EmbeddedLocalization in Optimizely CMS 12

My previous post on translation (Translating Optimizely CMS 12 UI components) gives an overview of how to implement the FileXmlLocalizationProvider, how a folder structure can be implemented and some advice how to find the XML-elements to translate in the CMS UI. This post will cover how to implement the alternative of FileXmlLocalizationProvider which is the EmbeddedXmlLocalizationProviderInitializer or commonly implemented using the AddEmbeddedLocalization extension method.

Unlike the FileXmlLocalizationProvider the EmbeddedLocalization utilize the EmbeddedResource project item in the .csproj file (https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#embeddedresource). This means instead of setting the path in the configuration in Startup.cs you instead set the include path in the .csproj file.

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

If using Visual Studio the file property dialogue will look like this

This will result in the XML language file being implemented as a resource in the stated project binary instead. In fact, any file you put in the included path will be added as a resource in the binary.

Modify your Startup file by adding

services.AddEmbeddedLocalization<Startup>();

Drawbacks

The only noteworthy drawback of this pattern is during development since it will require you to recompile when updating the XML language files while using the FileXmlLocalizationProvider will not.

There are some additional information on how to use language files in the official documentation, see https://docs.developers.optimizely.com/content-cloud/v12.0.0-content-cloud/docs/localizing-the-user-interface