volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Own language selector

Hi,
In EPiServer EDIT page, where you create new pages, you have a dropdown box at the bottom of the left menu that shows all the supported languages of the site. I need an own dropdown box in my startpage that shows exactly the same languages as the dropdown box in edit mode. How do I retreive the supported EPiServer languages from my code and populate my dropdown box with these?

Thanks
Mikael

#46112
Nov 28, 2010 11:27
PageDataCollection languagesForSomePage = EPiServer.DataFactory.Instance.GetLanguageBranches(somePageLink);

I usually do it like that. Then check pagedata.LanguageBranch for each item in the collection.

 

#46113
Edited, Nov 28, 2010 12:48

Thanks Johan,
Your code work fine, now I get the supported language codes, like "en", "sv" etc. But in episerver edit mode, at the "Show page tree:" dropdown list I can see the full name of the language, like "English", "Svenska" etc. Ofcourse I can do an own translator of the codes but I prefer to use the same translator as EPiServer use for this. Do you know how to do this, I mean...how do I get "English" instead of "en"?

#46147
Nov 30, 2010 12:48

You should have that as a property on LanguageBranch:

LanguageBranch branch = LanguageBranch.Load(pagedata.LanguageID);

#46148
Nov 30, 2010 12:52

Yiihaa, Thanks alot Johan, that solves my problem.

#46150
Nov 30, 2010 13:35
* 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.