Try our conversational search powered by Generative AI!

Kristoffer Lindén
Dec 30, 2021
  1568
(0 votes)

Handle translations in ViewConfiguration for CMS 12

In CMS 11 I had a view configuration that looked like this:

[ServiceConfiguration(typeof(ViewConfiguration))]
public class SendToTranslationView : ViewConfiguration<IContentData>
{
    public SendToTranslationView()
    {
        var localization = ServiceLocator.Current.GetInstance<LocalizationService>();
        Key = "SendToTranslationView";
        Name = localization.GetString("/Translations/ContentView/Name");
        Description = localization.GetString("/Translations/ContentView/Description");
        ControllerType = "epi-cms/widget/IFrameController";
        ViewType = "/MyPlugin/ContentTranslationHistory/Index";
        IconClass = "epi-iconCatalog epi-icon--medium";
    }
}

And after upgrading to CMS 12, the menu option no longer was translated even though the Thread.CurrentThread.CurrentUICulture was updated when changing the users UI language.
For some reason Name and Descrption no longer works in CMS 12 so the solution is to use LanguagePath instead.

This is how it should look:

[ServiceConfiguration(typeof(ViewConfiguration))]
public class SendToTranslationView : ViewConfiguration<IContentData>
{
    public SendToTranslationView()
    {
        Key = "SendToTranslationView";
        ControllerType = "epi-cms/widget/IFrameController";
        ViewType = "/MyPlugin/ContentTranslationHistory/Index"; 
        IconClass = "epi-iconCatalog epi-icon--medium";
        LanguagePath = "/Translations/ContentView";
    }
}

To get your menu option translated to English your language file then needs to contain:

<language name="English" id="en">
  <Translations>
    <ContentView>
      <Name>Translate content</Name>
      <Description>Choose what properties you want to translate and then mark your content</Description>
    </ContentView>
  </Translations>
</language>

So from now on, use LanguagePath instead of Name and Description in you ViewConfigurations

Dec 30, 2021

Comments

Please login to comment.
Latest blogs
Optimizely Search and Navigation - Part 2 - Filter Tips

Introduction Continuing from Part 1 – Search Tips , today I will share the next part – filter tips. The platform versions used for this article are...

Binh Nguyen Thi | Jul 1, 2024

Integrating HubSpot CRM without the MA Connector

Have HubSpot CRM? Want to push user data into it from Optimizely? Don’t have any personalisation requirements with that data? Don’t want to pay $80...

Matt Pallatt | Jun 27, 2024

Keeping the website secure by updating external packages

Did you see the latest warning from Optimizely to update this package with a critical security warning? https://world.optimizely.com/documentation/...

Daniel Ovaska | Jun 27, 2024

Optimizely CMS image anonymization now available for Linux!

The famous image anonymization add-on for Optimizely CMS, with at least 5 downloads, is now finally available for use on Linux. Supports simultaneo...

Tomas Hensrud Gulla | Jun 25, 2024 | Syndicated blog