Use invariant culture by default

This commit is contained in:
hishamco 2020-09-29 22:12:03 +03:00
parent 2924e7849f
commit f83c1b1741
3 changed files with 8 additions and 3 deletions

View File

@ -21,12 +21,16 @@ namespace Oqtane.Extensions
var configuration = app.ApplicationServices.GetService<IConfiguration>(); var configuration = app.ApplicationServices.GetService<IConfiguration>();
var defaultCulture = configuration.GetSection(DefaultCultureKey).Value; var defaultCulture = configuration.GetSection(DefaultCultureKey).Value;
var supportedCultures = configuration.GetSection(SupportedCulturesKey).Get<string[]>(); var supportedCultures = configuration.GetSection(SupportedCulturesKey).Get<string[]>();
if (defaultCulture == CultureInfo.InstalledUICulture.Name)
{
LocalizationSettings.DefaultCulture = defaultCulture;
}
if (supportedCultures.Length > 0) if (supportedCultures.Length > 0)
{ {
LocalizationSettings.SupportedCultures.AddRange(supportedCultures); LocalizationSettings.SupportedCultures.AddRange(supportedCultures);
} }
LocalizationSettings.DefaultCulture = defaultCulture;
CultureInfo.CurrentUICulture = new CultureInfo(defaultCulture); CultureInfo.CurrentUICulture = new CultureInfo(defaultCulture);
app.UseRequestLocalization(options => { app.UseRequestLocalization(options => {

View File

@ -13,7 +13,7 @@
"DefaultContainer": "" "DefaultContainer": ""
}, },
"Localization": { "Localization": {
"DefaultCulture": "en-US", "DefaultCulture": "",
"SupportedCultures": [] "SupportedCultures": []
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
namespace Oqtane.Shared namespace Oqtane.Shared
{ {
@ -60,6 +61,6 @@ namespace Oqtane.Shared
public static readonly string StalliteAssemblyExtension = ".resources.dll"; public static readonly string StalliteAssemblyExtension = ".resources.dll";
public static readonly string DefaultCulture = "en-US"; public static readonly string DefaultCulture = CultureInfo.InstalledUICulture.Name;
} }
} }