Copied to clipboard

Flag this post as spam?

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


  • David Zweben 268 posts 754 karma points
    Jun 30, 2016 @ 21:08
    David Zweben
    0

    Listing all languages configured in Umbraco w/Razor?

    Hi,

    I want to populate a dropdown menu on the front end of my site with a list of all of the languages configured in Umbraco under Settings > Languages. I want to include languages that aren't in use on any pages, though, so I can't do this by checking the language settings of nodes. How can this be done in dynamicnode Razor, in, say, a page template?

    Thanks!

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jun 30, 2016 @ 22:11
    Alex Skrypnyk
    101

    Hi David,

    Didn't use this method before but it looks what you need:

    var languages = ApplicationContext.Services.LocalizationService.GetAllLanguages();
    

    Cheers,

    Alex

  • David Zweben 268 posts 754 karma points
    Jul 01, 2016 @ 19:02
    David Zweben
    1

    Thank you, that did the trick. I was able to get the output I wanted as follows:

    var languages = ApplicationContext.Services.LocalizationService.GetAllLanguages();
    
    foreach (var language in languages)
    {
    @language.CultureName;
    <text> - </text>
    @language.IsoCode;<br>
    }   
    
  • 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