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 1444 posts 1855 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 1280 posts 3990 karma points MVP 7x 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 1444 posts 1855 karma points
    Aug 18, 2017 @ 07:51
    Gordon Saxby
    0

    Thanks Bjarne, that worked :-)

Please Sign in or register to post replies

Write your reply to:

Draft