Culture Picker issue

Topics: Troubleshooting
Jan 7, 2014 at 9:22 AM
Hi everyone,

I installed the lastest version of Orchard (1.7.2) as well as the Culture Picker (1.6.0.0) and the Localization (1.6) modules as I want to have a multilanguage website.

However I am unable to add the culture picker widget as it does not show in the widget list. Therefore I can't change the language on my website.

I wondered if you guys already saw this issue and if you could help me out.

Much appreciated
Jan 25, 2014 at 11:13 AM
Edited Jan 25, 2014 at 11:14 AM
working even with 1.x

read this
Feb 27, 2014 at 12:16 PM
I would also love to know more about Culture Picker for Orchard 1.7 / 1.x.

Thanks for a great module anyway.
Jun 24, 2014 at 6:18 PM
I'm using Orchard 1.8 with CulturePicker 1.6. Widget was also not available for me, but in logs I can see next:
2014-06-24 23:52:22,772 [28] Orchard.Environment.DefaultBuildManager - (null) - Error when compiling assembly under ~/Modules/Orchard.CulturePicker/Orchard.CulturePicker.csproj.
System.Web.HttpCompileException (0x80004005): d:\gitRepos\AssociationKG.git\Orchard.Source\src\Orchard.Web\Modules\Orchard.CulturePicker\Services\LocalizableMainMenuNavigationFilter.cs(27): error CS0246: The type or namespace name 'ContentMenuItemPart' could not be found (are you missing a using directive or an assembly reference?)
After commenting everything in
Modules\Orchard.CulturePicker\Services\LocalizableMainMenuNavigationFilter.cs
and restarting solution(or website), widget appears and works! But as you can guess commented code is responsible for localizable menus. For my luck I dont need this feature :)

Author of CulturePicker should update Modules\Orchard.CulturePicker\Services\LocalizableMainMenuNavigationFilter.cs to work with latest Orchard
Jul 22, 2014 at 5:37 PM
CulturePicker does not filter anymore main menu items on the current culture as did in Orchard 1.6, all menus are displayed together regardless of the culture of the related content item. The cause is the radical change in content items structure happened in Orchard 1.7+.

This is a fix to let LocalizableMainMenuNavigationFilter work properly with Orchard 1.8.1:

Orchard.CulturePicker/Services/LocalizableMainMenuNavigationFilter.cs
    public LocalizableMainMenuNavigationFilter(ICultureManager cultureManager, IWorkContextAccessor workContextAccessor, IOrchardServices orchardServices) {
        _cultureManager = cultureManager;
        _workContextAccessor = workContextAccessor;
        _orchardServices = orchardServices;
    }

    #region INavigationFilter Members

    public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> menuItems) {
        ILocalizableAspect localizationPart;
        string currentCulture = _cultureManager.GetCurrentCulture(_workContextAccessor.GetContext().HttpContext);

        foreach (MenuItem menuItem in menuItems) {
            if (menuItem.Content.Is<MenuPart>()) {
                // find the menu related content
                int routeId = (int)menuItem.RouteValues["Id"];
                // get the content item to retrieve the localization part
                ContentItem content = _orchardServices.ContentManager.Get(routeId, VersionOptions.Published);
                if (content == null) {
                    continue;
                }
                //NOTE: we can't use ILocalizationService.GetContentCulture for this, because it causes circular dependency
                localizationPart = content.As<ILocalizableAspect>();
            } else if (menuItem.Content.Is<MenuItemPart>()) {
                localizationPart = menuItem.Content.As<MenuItemPart>().ContentItem.As<ILocalizableAspect>();
            } else {
                localizationPart = menuItem.Content.As<ILocalizableAspect>();
            }
            // filter the menu item comparing with the current culture
            if (localizationPart == null
                || localizationPart.Culture == null
                || localizationPart.Culture == currentCulture)
                yield return menuItem;
        }
    }

    #endregion
}