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
Comments