Try our conversational search powered by Generative AI!

Kristoffer Lindén
Dec 30, 2021
  1506
(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
Why C# Developers Should Embrace Node.js

Explore why C# developers should embrace Node.js especially with Optimizely's SaaS CMS on the horizon. Understand the shift towards agile web...

Andy Blyth | May 2, 2024 | Syndicated blog

Is Optimizely CMS PaaS the Preferred Choice?

As always, it depends. With it's comprehensive and proven support for complex business needs across various deployment scenarios, it fits very well...

Andy Blyth | May 2, 2024 | Syndicated blog

Adding market segment for Customized Commerce 14

Since v.14 of commerce, the old solution  for adding market segment to the url is not working anymore due to techinal changes of .NET Core. There i...

Oskar Zetterberg | May 2, 2024

Blazor components in Optimizely CMS admin/edit interface

Lab: Integrating Blazor Components into Various Aspects of Optimizely CMS admin/edit interface

Ove Lartelius | May 2, 2024 | Syndicated blog