November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Looking at Translate() from LanguageManager -> it uses current UI culture (which is in your case is "sv").
return this.Translate(key, Thread.CurrentThread.CurrentUICulture.IetfLanguageTag);
Try to "restore" desired culture just before calling Translate().
AFAIK EPiServer content language really does not influence resource translation language.
EPiServer's current language context is lost when posting using ajax. Here is how you can set language context inside a web api call:
var language = ControllerContext.RouteData.Values["language"].ToString();
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
EPiServer.BaseLibrary.Context.Current["EPiServer:ContentLanguage"] = new CultureInfo(language);
Thank you all for the help. I have overridden InitializeCulture() method in the base class(for ajax pages) and used following code:
protected override void InitializeCulture()
{
base.InitializeCulture();
Thread.CurrentThread.CurrentUICulture = EPiServer.Globalization.ContentLanguage.PreferredCulture;
Thread.CurrentThread.CurrentCulture = EPiServer.Globalization.ContentLanguage.PreferredCulture;
}
Property
EPiServer.BaseLibrary.Context.Current["EPiServer:ContentLanguage"]
contain the correct culture even without any changes.
If you are using WebForms, it's an override of PageBase.
If you are using MVC, take a look at http://stackoverflow.com/questions/21160599/custom-language-handling-episerver
I have a site which uses EpiServer CMS 7.
I have a problem with the language of content which is returned after ajax call. For example, on some page I have a link, after clicking on it the AJAX-request will be sent to the server and content will be returned and inserted in special container. I have following url for AJAX request:
var urlStr= "/Folder1/Ajax/AddSomething.aspx?id=53&epslanguage=en&";
This link always contains the CORRECT language in "epslanguage" parameter. But content, which is returned after ajax call, is always in the default language(Swedish).
I have tried to debug and found that on AddSomething.aspx page I have following globalization settings:
System.Globalization.CultureInfo.CurrentUICulture == "sv";
System.Threading.Thread.CurrentThread.CurrentUICulture == "sv";
EPiServer.Globalization.ContentLanguage.PreferredCulture == "en";
Question: how can we set the correct language for the page content? As I understand, EpiServer knows the correct language, but still use "sv" when I call method
EPiServer.Core.LanguageManager.Instance.Translate(string str);
Thank you all in advance for the help.