зеркало из https://github.com/aspnet/Localization.git
CultureInfoCache.GetCultureInfo Should not be case sensitive
This commit is contained in:
Родитель
b22474afb3
Коммит
722fbc4ef5
|
@ -34,6 +34,7 @@ namespace CultureInfoGenerator
|
|||
// *************************** THIS FILE IS GENERATED BY A TOOL ***************************
|
||||
// To make changes to this file look at the CultureInfoGenerator project in this solution.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.Globalization
|
||||
|
@ -49,7 +50,7 @@ namespace Microsoft.Extensions.Globalization
|
|||
/// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it
|
||||
/// contains the latest culture names.
|
||||
/// </summary>
|
||||
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>
|
||||
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{{"
|
||||
);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// *************************** THIS FILE IS GENERATED BY A TOOL ***************************
|
||||
// To make changes to this file look at the CultureInfoGenerator project in this solution.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.Globalization
|
||||
|
@ -19,7 +20,7 @@ namespace Microsoft.Extensions.Globalization
|
|||
/// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it
|
||||
/// contains the latest culture names.
|
||||
/// </summary>
|
||||
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>
|
||||
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"",
|
||||
"af",
|
||||
|
|
|
@ -167,5 +167,31 @@ namespace Microsoft.Extensions.Localization.Tests
|
|||
var response = await client.GetAsync("/page?c=ar-SA&uic=ar-YE");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void GetTheRightCultureInfoRegardlessOfCultureNameCasing()
|
||||
{
|
||||
using (var server = TestServer.Create(app =>
|
||||
{
|
||||
var options = new RequestLocalizationOptions();
|
||||
var provider = new QueryStringRequestCultureProvider();
|
||||
provider.QueryStringKey = "c";
|
||||
provider.UIQueryStringKey = "uic";
|
||||
options.RequestCultureProviders.Insert(0, provider);
|
||||
app.UseRequestLocalization(options);
|
||||
app.Run(context =>
|
||||
{
|
||||
var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
|
||||
var requestCulture = requestCultureFeature.RequestCulture;
|
||||
Assert.Equal("fr", requestCulture.Culture.ToString());
|
||||
Assert.Equal("fr", requestCulture.UICulture.ToString());
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
}))
|
||||
{
|
||||
var client = server.CreateClient();
|
||||
var response = await client.GetAsync("/page?c=FR&uic=FR");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче