fliags instead of dropdown in culture picker

Topics: Localization
Nov 3, 2011 at 1:36 PM

Hi all,

I am using culture picker and i have created multilanguage website in orchard .But now i want to put country flags instead of dropdown for selecting culture.

So please do needful.

Coordinator
Nov 3, 2011 at 6:48 PM

With shape tracing, you should be able to see what template renders the dropdown and create an override or an alternate for it in your theme. You might want to contact the author of that module if that doesn't work.

Dec 31, 2011 at 1:20 AM

Hello!

Can you please tell me how to change the «DropDownList» icon on the flags.

Coordinator
Dec 31, 2011 at 5:30 AM

You should ask the author of that module.

Jan 2, 2012 at 3:47 PM

I've done this earlier for a website of mine so i will place it here hopefully tommorrow.

Jan 2, 2012 at 5:52 PM

Thank you for your support!

The author of the module Orchard.CulturePicker, helped me to understand, and that's what happened:

@using Orchard.Utility.Extensions
@using System.Collections.Generic
@using System.Globalization

@{
    var availableCultures = Model.AvailableCultures as List<string>;

    var availableCultureswithNames = new List<KeyValuePair<string, string>>(availableCultures.Count);
    foreach (var culture in availableCultures) {
        try {
            var cultureInfo = new CultureInfo(culture);
            availableCultureswithNames.Add(new KeyValuePair<string, string>(culture, cultureInfo.NativeName));
        }
        catch {
            availableCultureswithNames.Add(new KeyValuePair<string, string>(culture, culture));
        }
    }
}

@using (Html.BeginForm("ChangeCulture", "UserCulture", new { Area = "Orchard.CulturePicker" })) {
    
    <div class="changeCulture">
        @*<label for="CultureName">@T("Language")</label>*@
        <ul>
            @foreach (var item in availableCultureswithNames) {
                <li>
                    @if (item.Key == Model.UserCulture) {
                        <a href="@Url.Action("ChangeCulture", "UserCulture", new { Area = "Orchard.CulturePicker", cultureName = item.Key })" title="@item.Value">
                        <img src="@("/Themes/Contoso/Content/images/flags/" + item.Key + ".png")" alt="@item.Key" /></a>
                    }
                    else {
                        <a href="@Url.Action("ChangeCulture", "UserCulture", new { Area = "Orchard.CulturePicker", cultureName = item.Key })" title="@item.Value">
                        <img src="@("/Themes/Contoso/Content/images/flags/" + item.Key + ".png")" alt="@item.Key" /></a>
                    }
                </li>
            }
        </ul>
    </div>
}