November Happy Hour will be moved to Thursday December 5th.

Fallback language

Vote:
 

I have a page that is translated to different languages. I have setup language fallback (if someone wants to view a page in language A but that language branch does not exists for that page then it should show the page in language B).

This page also has a content area.

I a page exists in language A and B but only has content in the content area in language B then I want to be able to get the content in the content area for language B when I will show the page in language A.

The thing I want to know is how I can find out what the fallback language is for that instance of page?!

#139279
Sep 29, 2015 10:26
Vote:
 

Hi,

Here is a code snippet that returns the list of fallback languages:

ContentReference currentReference = ...

var currentLanguage = EPiServer.Globalization.ContentLanguage.PreferredCulture.Name;

var fallbackLanguages = EPiServer.Core.ContentLanguageSettingsHandler.Instance.GetFallbackLanguages(currentReference, currentLanguage);
#139304
Sep 29, 2015 13:00
Vote:
 
#139319
Sep 29, 2015 22:09
Vote:
 

Thanks!

That one works fine for EPiServer 7.5 but we have 7.1 so I just had to modify how I get the fallback languages:

var fallbackLanguages = PageLanguageSettingsTree.Instance.GetFallbackLanguages(Model.PageLink, Model.LanguageBranch);
#139333
Sep 30, 2015 10:37
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.