Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Mar 02, 2016 @ 16:46
    Craig100
    1

    Vorto - list all languages in use

    Umb 7.4.1 & Vorto 1.5.0

    I have the following code that is switching languages nicely. However it's showing ALL languages installed rather than just the languages in use. I noticed Vorto manages to get a list of "in use" languages. Is it possible at the front end and how would you do it?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using System.Globalization;
    @using Umbraco.Core;
    @{
        var thisPage = Model.Content.Url;
        var currentLang = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
        var localService = ApplicationContext.Current.Services.LocalizationService;
    
        <div class="col-xxs-6 col-s-3 col-m-2 lang-switch push">
            @foreach (var lang in localService.GetAllLanguages()) {
                var thisLang = lang.CultureInfo.TwoLetterISOLanguageName;
                var currentPage = Model.Content.UrlName;
                var url = Model.Content.DocumentTypeAlias == "homePage"
                            ? "/" + thisLang
                            : "/" + thisLang + currentPage;
                var activeClass = currentLang == thisLang ? " active" :  "";            
            <div class="lang pull@(activeClass)"><a href="@url">@thisLang.ToUpper()</a></div>
            }       
        </div>
    }
    

    Thanks,

    Craig

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Mar 02, 2016 @ 21:36
    Dennis Aaen
    0

    Hi Craig,

    Have you seen the uHangout episode on how Vorto works, if not try to see this episode here http://uhangout.co.uk/videos/ep029-with-matt-brailsford-multi-language-translation-with-vorto/

    7 minitues in to the episode, Matt takes about how to configure the Vorto so you only get the list of the languages that is used by the website, and the languages needs to be assigned as a hostname in your Umbraco installation.

    Hope this helps,

    /Dennis

  • Craig100 1136 posts 2523 karma points c-trib
    Mar 03, 2016 @ 00:28
    Craig100
    0

    Hi Dennis,

    Yes that's about the back end, my question is about the front end. I'm building a language switcher partial. I want to be able to just list the languages that are used, like Vorto can in it's dateType, but on the front end, and without using anything nasty that would slow the front end down like the contentservice :) I guess it's more of a Vorto question than an Umbraco question really.

  • Craig100 1136 posts 2523 karma points c-trib
    Mar 03, 2016 @ 13:54
    Craig100
    0

    Or.... Putting it another way.......

    How can you list the languages and/or cultures set on the site in the Culture and Hostnames settings?

    :)

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Mar 03, 2016 @ 19:47
    Dennis Aaen
    0

    Hi Craig,

    DonĀ“t know if this article from the Umbraco advent calendar from 2014 http://24days.in/umbraco/2014/razor-language-switcher/ can help you to build a language switcher

    Hope this helps, or inspires you to a solution.

    /Dennis

  • Craig100 1136 posts 2523 karma points c-trib
    Mar 03, 2016 @ 20:00
    Craig100
    0

    Hi Dennis,

    That article is for a one site per language implementation, not a Vorto one site for all languages implementation.

    My language switcher works fine (see code above). It's just that it's showing all languages that have been added to the Settings/Languages section whereas what I want is to show all languages added to the site's Culture and Hostnames settings, that's all. I could remove languages from the settings to achieve the same display on the language switcher but I wondered if there was a better way.

  • Simone Chiaretta 134 posts 541 karma points c-trib
    Mar 03, 2016 @ 20:31
    Simone Chiaretta
    0

    I've the same problem.

    The solution I found is to check one property that I'm sure is filled if a page has been translated and see which languages it has.

Please Sign in or register to post replies

Write your reply to:

Draft