Use the referrer to determine the language if it is a POST

This commit is contained in:
Nicholas Mayne
2014-09-16 15:39:45 +01:00
parent c4387ab54c
commit 24530f09bd
3 changed files with 9 additions and 9 deletions

View File

@@ -30,4 +30,4 @@ Features:
Description: Enabled transliteration of the slug when creating a piece of content
Category: Content
Name: Url Transliteration
Dependencies: Orchard.Localization.Transliteration
Dependencies: Orchard.Localization.Transliteration, Orchard.Autoroute

View File

@@ -52,18 +52,12 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>

View File

@@ -34,9 +34,15 @@ namespace Orchard.Localization.Providers {
if (!IsActivable(context))
return null;
var content = GetByPath(context.Request.Path.TrimStart('/'));
var path = context.Request.Path;
if (context.Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase)
&& context.Request.UrlReferrer != null) {
path = context.Request.UrlReferrer.AbsolutePath;
}
var content = GetByPath(path.TrimStart('/'));
if (content != null) {
return new CultureSelectorResult {Priority = -1, CultureName = _localizationService.Value.GetContentCulture(content)};
return new CultureSelectorResult { Priority = -1, CultureName = _localizationService.Value.GetContentCulture(content) };
}
return null;