0
klainer created
i have this resource localizable attribute:
public class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
public LocalizedDisplayNameAttribute(string resourceId)
: base(GetMessageFromResource(resourceId))
{
}
private static string GetMessageFromResource(string resourceId)
{
var ioc = Abp.Dependency.IocManager.Instance;
var localizationManager = ioc.IocContainer.Resolve<ILocalizationManager>();
return localizationManager.GetString(MMMConsts.LocalizationSourceName, resourceId, Thread.CurrentThread.CurrentUICulture);}
When I switch language in WEB app, and debug this, In Thread.CurrentThread.CurrentUICulture i still the same value.
But when do this in Razor view culture has changed correctly.
How can I setUp currencu culture in my attribute class , I need it for loading multilanguages texts from resources.
Model attributes are initialized before app start ? Thanks for help !
Solved by this code:
public LocalizedDisplayNameAttribute(string resourceKey)
: base(resourceKey)
{
ResourceKey = resourceKey;
}
public string ResourceKey { get; set; }
public override string DisplayName
{
get
{
string value = null;
var ioc = Abp.Dependency.IocManager.Instance;
var localizationManager = ioc.IocContainer.Resolve<ILocalizationManager>();
value = localizationManager.GetString(MMMConsts.LocalizationSourceName, ResourceKey, Thread.CurrentThread.CurrentUICulture);
return value;
}
}
c# asp.net-mvc