Currently I'm using Orchard 1.9
with different Main Menus
on Culture Layers
(en/de). For regular (translated) Content it is working.
But for Custom Modules/Pages like User/Account or MyModule/List the Menu is not appearing at all.
How can I fix this issue?
I am not aware of any filter that sets the attribute, but you can definitely write an action filter to do the same.
If culture is being resolved through routing, use the following code:
using System.Globalization;
using System.Threading;
using System.Web.Mvc;
public class CultureAttribute : ActionFilterAttribute {
public override void OnActionExecuting(ActionExecutingContext filterContext) {
string language = (string)filterContext.RouteData.Values["language"] ?? "en";
string culture = (string)filterContext.RouteData.Values["culture"] ?? "US";
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture));
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture));
}
}
If you have culture info set in your session variables use this code:
using System.Globalization;
using System.Threading;
using System.Web.Mvc;
public class CultureAttribute : ActionFilterAttribute {
public override void OnActionExecuting(ActionExecutingContext filterContext) {
string language = (string)filterContext.HttpContext.Session.Contents["language"] ?? "en";
string culture = (string)filterContext.HttpContext.Session.Contents["culture"] ?? "US";
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture));
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With