mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Localize IPC (#2431)
* Localize IPC * Keep logs in one language * Cleanup * Revert changes that keep strings in one locale * Order dependencies alphabetically * Fix formatting (Thanks, Rider -.-)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Localization" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" />
|
||||
|
||||
@@ -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<RequestLocalizationOptions>(
|
||||
#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<IRequestCultureProvider> { new AcceptLanguageHeaderRequestCultureProvider() };
|
||||
}
|
||||
);
|
||||
|
||||
// Add support for proxies
|
||||
services.Configure<ForwardedHeadersOptions>(
|
||||
options => {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.ResponseCaching" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
|
||||
|
||||
Reference in New Issue
Block a user