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
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