Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1347 posts 1608 karma points
    Aug 17, 2017 @ 15:36
    Gordon Saxby
    2

    Get list of Languages for a node

    I am using Vorto to create a multi-language website. The home node has a number of domains and languages assigned using "Culture and Hostnames" - e.g.

    enter image description here

    How can I get a list of the languages using C# ?

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Aug 18, 2017 @ 07:35
    Bjarne Fyrstenborg
    103

    Hi Gordon

    You should be able to get the added languages in backoffice using LocalizationService.

    IEnumerable<ILanguage> languages = ApplicationContext.Current.Services.LocalizationService.GetAllLanguages();
    

    To get the languages/cultures for the assigned hostnames, I think you should use DomainService, where

    int contentId = 1234;
    IDomainService domainService = ApplicationContext.Current.Services.DomainService;
    IEnumerable<IDomain> domains = domainService.GetAssignedDomains(contentId, true);
    

    You can read more about the services in the documentation here https://our.umbraco.org/apidocs/csharp/

    /Bjarne

  • Gordon Saxby 1347 posts 1608 karma points
    Aug 18, 2017 @ 07:51
    Gordon Saxby
    0

    Thanks Bjarne, that worked :-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies