Copied to clipboard

Flag this post as spam?

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


  • shivangi 1 post 71 karma points
    Feb 12, 2021 @ 08:01
    shivangi
    0

    How to add dropdown for multiple languages so that website visitors can change the language.

    Hello,

    I have created a new .net framework project with the latest version of Umbraco (8.1). I want to add multiple languages to my website. I have already added multiple languages from the Umbraco backend but I want to add a dropdown on the frontend side so that the visitors of the website can change the language as per requirement.

    Please help me adding the dropdown in the cshml pages and other required changes so that I can get the options for the dropdown from the Umbraco backend with the languages that I have added to the culture.

    Thanks in Advance

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Feb 14, 2021 @ 15:58
    Huw Reddick
    1

    Check out this post

    https://our.umbraco.com/forum/umbraco-8/95909-umbraco-v8-multilanguage

    It should provide the info you require

  • Nikhil Prajapati 19 posts 131 karma points
    Sep 12, 2022 @ 09:41
    Nikhil Prajapati
    0

    Hello,

    I'm not sure you got your answer or not but as I am seeing this question as unanswered, so thought to help you out.

    Checkout below code for multiple languages dropdown on website.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using Umbraco.Web
    @using System.Globalization
    @{
        // languages
        var languages = Model.Root().Cultures;
    
    }
    <div class="langs">
        <ul>
            @foreach (var (culture, infos) in languages)
            {
                var c = new CultureInfo(culture);
                <li class="notranslate" lan-code="@c.Name" href="@Model.Url(culture)">
                    @c.NativeName @*name of language*@
                    @c.ThreeLetterISOLanguageName @*name of iso code*@
                </li>
            }
        </ul>
    </div>
    

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft