diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index 261602b46..97467801f 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -35,6 +35,7 @@ + diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index d7402cae8..81c75bda4 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -40,6 +40,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Headers; using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -54,11 +55,10 @@ namespace ArchiSteamFarm.IPC { public Startup(IConfiguration configuration) => Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); -#if NETFRAMEWORK [UsedImplicitly] +#if NETFRAMEWORK public void Configure(IApplicationBuilder app, IHostingEnvironment env) { #else - [UsedImplicitly] public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { #endif if (app == null) { @@ -140,6 +140,8 @@ namespace ArchiSteamFarm.IPC { } ); + app.UseRequestLocalization(); + // Use routing for our API controllers, this should be called once we're done with all the static files mess #if !NETFRAMEWORK app.UseRouting(); @@ -211,6 +213,22 @@ namespace ArchiSteamFarm.IPC { } } + services.AddLocalization(); + +#if NETFRAMEWORK + services.Configure( +#else + services.AddRequestLocalization( +#endif + static options => { + // We do not set the DefaultRequestCulture here, because it will default to Thread.CurrentThread.CurrentCulture in this case, which is set when loading GlobalConfig + options.SupportedUICultures = options.SupportedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures); + + // The default checks the URI and cookies and only then for headers; ASFs IPC does not use either of the higher priority mechanisms anywhere else and we don't want to start here. + options.RequestCultureProviders = new List { new AcceptLanguageHeaderRequestCultureProvider() }; + } + ); + // Add support for proxies services.Configure( options => { diff --git a/Directory.Packages.props b/Directory.Packages.props index 21494fced..21ec04762 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -32,6 +32,7 @@ +