enabled languages for a page

Marcus Hansson
Member since: 2008


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
  • Per Bjurström
    Member since: 1999

    LanguageBranch.ListEnabled() in namespace EPiServer.DataAbstraction.


    #29047 Apr 02, 2009 14:54
  • Per Bjurström
    Member since: 1999

    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
  • Marcus Hansson
    Member since: 2008

    Thank you, I will try this tomorrow!

    #29051 Apr 02, 2009 16:09
  • Marcus Hansson
    Member since: 2008

    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
    Member since: 2006

    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>()
    .Where(language => !myPage.ExistingLanguages.Contains(language.Culture)
    .Select(language => language.Culture);
    #118411 Edited, Mar 05, 2015 16:13