Sitecore appears to be doing something freaky with the language variable in it's Context object. If I load a CMS page using the url ?sc_Lang=ru-RU
(get the Russian version of my site), by the time it get's to my MVC controller it's reset to the language back to en
public PartialViewResult Navigation()
{
//en
var language = Sitecore.Context.Language;
}
I know that sitecore does set this at some point because if I add a HTTP pipeline I can see Sitecore.Context.Language
as ru-RU
:
public class LanguageResolver
{
public void Process(Sitecore.Pipelines.HttpRequest.HttpRequestArgs args)
{
//ru-RU
var language = Sitecore.Context.Language;
}
}
Registered:
<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/>
<processor type="namespace.LanguageResolver,RR.Web.Sc.Extensions" patch:source="Languages.config"/>
as recommended on the sitecore blog post
I did some digging into the sitecore dlls and I noticed that Sitcore.Context.Language
is basically a wrapper for HttpContext.Current.Items["sc_Language"]
. When I inspect this I see the same results (i.e. in the pipeline it's ru-RU
in the controller it's en
)
So something somewhere is turning this HttpContext
Item
to "en"
.
As an experiment I dropped a new variable into the Items
collection. I can then see this again (in it's correct state) in Controller, so the Items collection is getting passed into the controller correctly.
I didn't originally develop this site but I can't see anywhere in the code base that changes this language variable.
Has anyone else experienced this? Anything I've missed? Anything I need to configure, check?
The sitecore docs (as usual) are pretty woeful on this subject.
To follow up on the comment from @jammykam:
I can see the lang cookie the Response Set-Cookie: redrow#lang=ru-RU; path=/
and the languages are set up: