Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Content type localization and inheritance

Vote:
 

Hello,

I am struggling with an issue with inheritance in respect to localization of content types. I have several base classes (content types) that all contain their own properties that I’d like to translate into multiple languages.

The following is a simplified example to explain my problem:

(The classes are of course in reality set as content types with their own GUID etc.)

public class SitePageData : PageData
{
	public virtual bool HideSiteHeader { get; set; }
	public virtual bool HideSiteFooter { get; set; }
}

public class ArticleSitePage : SitePageData 
{
	public virtual string MainBody { get; set; }
	public virtual bool HideRelatedArticles { get; set; }
}

public class ArticlePage : ArticleSitePage 
{
}

public class NewsArticlePage : ArticleSitePage
{
}

Is it possible to make something like the following work?



  
    
      
        Site page data
        Site page data description
        
          
            Hide header
            Set true to hide the header
          
          
            Hide footer
            Set true to hide footer
          
        
      
      
        Article site page
        Article site page description
        
          
            Main body
            This is the page's main body
          
          
            Hide related articles
            Set true to hide the related articles section
          
        
      
      
        Article page
        Description for article page
      
      
        News article page
        Description for news article page
      
    
  

When I create a new NewsArticlePage I would like all its properties inherited from its base classes to be translated with respect to this XML. Currently I can’t get this to work and the only workaround I can figure is to manually translate all properties for all pages, which results in a lot of duplicate text.

Thanks in advance for any responses.

#175168
Feb 14, 2017 12:17
Vote:
 

That should work, and your structure looks correct to me. Keep in mind that you'll have to restart the site to get the updated values though. And make sure you clear the cache.

#175175
Feb 14, 2017 14:48
Vote:
 

No, but you can create common translation for PageData (I think) and IContentData

	<contenttypes>
		<!-- Common property names shared between all IContentData -->
		<icontentdata>
			<properties>
				<PageTitle>
					<caption>Title</caption>
				</PageTitle>
			</properties>
		</icontentdata>
	</contenttypes>
#175176
Feb 14, 2017 14:48
Vote:
 

I know for sure that it doesn't work that well for blocks. E.g. if you use a block as a property you cannot have common translations for BlockData.

#175177
Feb 14, 2017 14:50
Vote:
 

Are you sure about that, Johan? It works on an alloy site

Edit: For page types that is

#175178
Edited, Feb 14, 2017 14:50
Vote:
 

Not 100% sure. But pretty sure I've tested this without any luck. I know for sure that having common translations for local blocks / blocks as properties doesn't work. I reported this as a bug, because it used to work in previous versions of Episerver, but it was not accepted as a bug and won't be fixed.

#175183
Feb 14, 2017 15:08
Vote:
 

This I know works:

	<contenttypes>
		<!-- Common property names shared between all IContentData -->
		<icontentdata>
			<properties>
				<PageTitle>
					<caption>Title</caption>
				</PageTitle>
			</properties>
		</icontentdata>
 		<pagedata>
			<properties>
				<PageTitle>
					<caption>Title</caption>
				</PageTitle>
			</properties>
		</pagedata>
		<blockdata>
			<properties>
				<PageTitle>
					<caption>Title</caption>
				</PageTitle>
			</properties>
		</blockdata>
	</contenttypes>

But if you use a block as a property, the above common translations in <blockdata> will not apply. You have to have specific translations for the exact block data type.

#175184
Feb 14, 2017 15:11
Vote:
 

In an Alloy site, running Episerver 10, it works. For instance, the NewsPage type could inherit the translation values located in the<sitepagedata> or <standardpage>  sections. That is for simple properties though. I did not try with blocks - but I trust that you are correct :-)

#175186
Feb 14, 2017 15:21
Vote:
 

Hi guys,

Thanks for your replies! It appears that it does work and that I was in fact having a caching problem. Is there a good way to force an update for stuff like this? I have tried to restart the website in IIS and also did a rebuild of the solution but the cache persists.

#175206
Feb 14, 2017 18:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.