mirror of
https://github.com/duplicati/duplicati.git
synced 2026-05-10 09:09:39 -04:00
9f79025744
Re-implemented everything using ASP.NET. Changed some requests to use JSON instead of FORM data. Some work towards deleting the FIXMEGlobal instance. Auth is missing, XSRF does not work correctly.
22 lines
884 B
C#
22 lines
884 B
C#
using Duplicati.WebserverCore.Abstractions;
|
|
|
|
namespace Duplicati.WebserverCore.Services
|
|
{
|
|
public class LanguageService(IHttpContextAccessor httpContext) : ILanguageService
|
|
{
|
|
private static IEnumerable<string> GetLanguageStrings(HttpRequest? request)
|
|
=> request?.GetTypedHeaders()
|
|
.AcceptLanguage?
|
|
.OrderByDescending(x => x.Quality ?? 1)
|
|
.Select(x => x.Value.ToString())
|
|
?? [];
|
|
|
|
private static System.Globalization.CultureInfo? GetLanguage(IEnumerable<string> languages)
|
|
=> languages
|
|
.Select(x => Library.Localization.LocalizationService.ParseCulture(x))
|
|
.FirstOrDefault(x => x != null);
|
|
|
|
public System.Globalization.CultureInfo? GetLanguage()
|
|
=> GetLanguage(GetLanguageStrings(httpContext.HttpContext?.Request));
|
|
}
|
|
} |