I have a very unusual problem that completely surpassed me. We have a multilingual website, so we use resource files. However, every piece of text in our minds that was burnt like <a href="#">@TextResources.my_key</a>will be localized in a random culture. This only happens when deploying Azure, I cannot play locally.
Adding to the riddle is that there is a single bit of text that ALWAYS respects my cultural change. This text is retrieved using a method call:
<a href="#">@.ConfigUtils.getTerms()</a>
Method:
public static string getTerms()
{
string key = GetKeyFromDb(CONSTANTS.TERMS);
if (!string.IsNullOrEmpty(key))
{
return TextResources.ResourceManager.GetString(key);
I am still reading from our resource file, but in this context it is localized as desired! Is the culture used after reading the resource file in the view, but before calling this method ?!
, OnActionExecuting() :
protected override void OnActionExecuting(ActionExecutingContext filterContext) {
ContextModel ctx = (ContextModel) Session["ContextModel"];
if (ctx != null && ctx.UserLanguageId != null){
Thread.CurrentThread.CurrentUICulture = new CultureInfo (ctx.UserLanguageId);
Thread.CurrentThread.CurrentCulture = new CultureInfo(ctx.UserLanguageId);
}
}
Azure , , , - , , , .
OnActionExecuting() , , . - ?
UPDATE
, , .
2
@RichardSchneider TextResources :
public static string my_key{
get {
return ResourceManager.GetString("my_key", resourceCulture);
}
}