Try our conversational search powered by Generative AI!

Kristoffer Lindén
Dec 30, 2021
  1512
(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
A day in the life of an Optimizely Developer - Enabling Opti ID within your application

Hello and welcome to another instalment of A Day In The Life Of An Optimizely developer, in this blog post I will provide details on Optimizely's...

Graham Carr | May 9, 2024

How to add a custom property in Optimizely Graph

In the Optimizely CMS content can be synchronized to the Optimizely Graph service for it then to be exposed by the GraphQL API. In some cases, you...

Ynze | May 9, 2024 | Syndicated blog

New Security Improvement released for Optimizely CMS 11

A new security improvement has been released for Optimizely CMS 11. You should update now!

Tomas Hensrud Gulla | May 7, 2024 | Syndicated blog

Azure AI Language – Key Phrase Extraction in Optimizely CMS

In this article, I demonstrate how the key phrase extraction feature, offered by the Azure AI Language service, can be used to generate a list of k...

Anil Patel | May 7, 2024 | Syndicated blog

Webinar: Get Started with AI within Optimizely CMS

Join us for the webinar "Get Started with AI in Optimizely CMS" on Wednesday, May 8th. Don't forget to register!

Luc Gosso (MVP) | May 7, 2024 | Syndicated blog

Search & Navigation: Indexing job new features

From Episerver.Find version 16.1.0, we introduced some new features that make the indexing job in CMS more flexible and efficient: Support continuo...

Vinh Cao | May 7, 2024