Try our conversational search powered by Generative AI!

enabled languages for a page

Vote:
 

Hi

I have a slight problem, I need to get all enabled languages for a site, the problem is that when I use GetLanguageBranches I only get the languages which the page has been created in. 
I need to be able to get all languages so that i can use CreateLanguageBranch for each enabled langugage on the page I create, is there another way to get these enabled languages for a site? 

#29004
Apr 02, 2009 8:50
Vote:
 

LanguageBranch.ListEnabled() in namespace EPiServer.DataAbstraction.

 

#29047
Apr 02, 2009 14:54
Vote:
 

Or PageLanguageSettingsTree.Instance in EPiServer.Core if you need to take into account that the editor has restricted different language for different pages.

 

#29048
Apr 02, 2009 14:58
Vote:
 

Thank you, I will try this tomorrow!

#29051
Apr 02, 2009 16:09
Vote:
 

I guess I should have said that I use EpiServer 4.62b also.

I currently implemented the workaround that I use the languages from the parent-page and that way I can get the relevant languages. And List() gets all languages available in the whole EpiServer.

What I need it for is, when I publish a page on the english-language site, it will search and find all pages, on other sites, which have a "MasterPage" property set to this page and create a new version of this english page in the different languages on the others sites. For example, when i publish a english news-page it will create a new version on another site which has Swedish and Danish languages enabled so that they can translate the page into those languages and then publish it.
But if no language is previously created on this page it will only find the currently created language, what I need is to find all languages available on this site, in this case, Swedish and Danish.

#29060
Edited, Apr 03, 2009 9:05
Ted
Vote:
 

In EPiServer 8 you can do something like the following to find all enabled languages for a site and find out which languages are missing for a specific page (for example to automatically create "missing" language versions):

var languagesNotYetCreatedForPage = ServiceLocator.Current.GetInstance<ILanguageBranchRepository>()
.ListEnabled()
.Where(language => !myPage.ExistingLanguages.Contains(language.Culture)
.Select(language => language.Culture);
#118411
Edited, Mar 05, 2015 16:13
* 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.