Try our conversational search powered by Generative AI!

MVC - Translate ContentType parameters

Vote:
 

Is it possible to add translations to ContentType parameters like DisplayName and Description?

#75121
Sep 18, 2013 11:30
Vote:
 

In /Resources/LanguageFiles you should have a file named ContentTypeNames.xml. In this file you put in the different strings for name and description:

Example:

<?xml version="1.0" encoding="utf-8" ?>
<languages>

  <language name="Norsk (bokmål)" id="no">
    
    <pagetypes>
      <pagetype name="StartPage">
        <name>Startside</name>
        <description>Info om startside</description>
      </pagetype>
    </pagetypes>
    
    <blocktypes>
      <blocktype name="SomeBlock">
        <name>Blokk</name>
        <description>Info om blokk</description>
      </blocktype>
    </blocktypes>

  </language>
  
  <language name="English" id="en">

    <pagetypes>
      <pagetype name="StartPage">
        <name>Start page</name>
        <description>Info about the start page</description>
      </pagetype>
    </pagetypes>

    <blocktypes>
      <blocktype name="ToolLinkBlock">
        <name>Block</name>
        <description>Info about the block</description>
      </blocktype>
    </blocktypes>
    
  </language>

</languages>

    

In the pages and blocks you create you don't (or shouldn't?) have to specify name and description in the ContentType attribute.

Example:

namespace Project.Models.Pages
{
    [ContentType(Order = 100, GUID = "fddca5cc-dfdc-4ca4-a176-1a3e52e18490")]
    public class StartPage
    {
        //Properties
    }
}

 

#75127
Sep 18, 2013 13:05
Vote:
 

Just to clarify Robert's response... The location of the language files is configurable in EPiServerFramework.config. If you don't have the localization provider configured, you can add it in and change around any fallback behavior:

<localization fallbackBehavior="Echo, MissingMessage, FallbackCulture" fallbackCulture="en-US">
    <providers>
        <add virtualPath="~/Resources/LanguageFiles" name="languageFiles" type="EPiServer.Framework.Localization.XmlResources.FileXmlLocalizationProvider, EPiServer.Framework" />
    </providers>
</localization>

The actual name of the .XML file that you use doesn't matter. I'd name it that for organizational purposes. There's no requirements in how you name the file.

For this case though, the names of the XML elements does matter, and should be as what Robert posted.

http://cjsharp.com/blog/2013/04/11/working-with-localization-and-language-branches-in-episerver-7-mvc/

#75144
Sep 18, 2013 15:32
Vote:
 

Thank you Chris and Robert for your responses!

#75147
Sep 18, 2013 15:50
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.