Fallback languages

Vote:
 
In EPiServer multi language environments, you can use the DefaultLanguage property on pages to set a fallback language if one language is not published. Is there any way to specify multiple fallbacks? Ex. One page has Norwegian, Swedish and English. On the Swedish version I want to fall back to Norwegian, on the Norwegian page I want to fall back to Swedish, and if none of these are set, I want to fall back to English. Possible?
#12261
Mar 25, 2008 18:34
Vote:
 
Hi again. Anyone got any input on this? Any feedback, or questions perhaps, is welcome :)
#13937
Mar 25, 2008 18:43
Vote:
 
Hello! The current version does not support this behaviour. I added this as a functionality request (issue #32983). I think the best way to this is to add a language coded dynamic property that specifies in what order languages should be probed. This makes it possible to set the probe order for every language for different parts of the web site. Example: LanguageProbeOrder___SV = "NO,EN" LanguageProbeOrder___NO = "SV,EN"
#13938
Mar 25, 2008 18:43
Vote:
 
Thank you, Linus. Any input on how to best use this approach when trying to render the page? Do I have to set the CurrentPage.LanguageID or something in run-time?
#13939
Mar 25, 2008 18:43
Vote:
 
Here is some sample code for a base class that adds some fallback functionality for a page. You could probably add the functionality you want to this class and inherit from this instead of apgebase for your multi language pages: public class TemplatePageMultiLang : TemplatePage { private bool isLangValidated = false; public override PageData CurrentPage { get { if (!isLangValidated) { isLangValidated = true; PageData p = EPiServer.Global.EPDataFactory.GetPage( CurrentPageLink, EPiServer.Security.AccessControlList.NoAccess); if (!EPiServer.Util.MultiLanguageRuntime.LanguageIsTranslated( p.Property, LanguageManager.GetContextLanguage(null))) { if (EPiServer.Util.MultiLanguageRuntime.LanguageIsTranslated( p.Property, "SV")) { HttpContext.Current.Items["epslanguage"] = "SV"; } else if (EPiServer.Util.MultiLanguageRuntime.LanguageIsTranslated( p.Property, "NO")) { HttpContext.Current.Items["epslanguage"] = "NO"; } } } return base.CurrentPage; } } }
#13940
Mar 25, 2008 18:43
Vote:
 
Thank you for feedback on this. I've encountered another challenge: In our multilanguage site we have not always translated the pages. If the pages are translated, all the flags for these languages should appear on the page for the user to select. This I have managed, so so far, so good. When however, the user first select to view the current page in another language, I set the language on the current page to that which he or she selected. But when the user after this goes to another page that is not translated in the language he or she selected , I want it to view a default language, one that always should be translated and published (f.ex. Norwegian). I'm a little confused on how to best accomplish this. Should I use Session, or HttpContext? When do I have to redirect, and when do I not? Where in the loading process do I have to do this (i.e. Page_Load, Page_Init, or earlier?) Thanks for any input on this. Frank :)
#13941
Mar 25, 2008 18:43
Vote:
 
The HttpContext should be used when you want to set the language for the current request. This can be used if you always want to set the language depending on the requested url. You should do this early in the page life cycle, Page_Init or Application_BeginRequest. The session object or cookie should be used when you want the user to have the selected language until it is changed. A redirect should be used after this value is changed to reload the page with the new language.
#13942
Mar 25, 2008 18:43