1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

Fixed: Fallback to English translations if invalid UI language in config

(cherry picked from commit 4c7201741276eccaea2fb1f33daecc31e8b2d54e)

Close #9112
This commit is contained in:
Stevie Robinson
2023-09-01 02:47:38 +02:00
committed by Bogdan
parent 14b9dd77af
commit 093bb94e42
4 changed files with 23 additions and 1 deletions

View File

@@ -531,6 +531,7 @@
"InteractiveSearchResultsFailedErrorMessage": "Search failed because its {message}. Try refreshing the movie info and verify the necessary information is present before searching again.",
"Interval": "Interval",
"InvalidFormat": "Invalid Format",
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
"KeepAndUnmonitorMovie": "Keep and Unmonitor Movie",
"KeyboardShortcuts": "Keyboard Shortcuts",
"Language": "Language",

View File

@@ -87,7 +87,7 @@ namespace NzbDrone.Core.Localization
public string GetLanguageIdentifier()
{
var isoLanguage = IsoLanguages.Get((Language)_configService.UILanguage);
var isoLanguage = IsoLanguages.Get((Language)_configService.UILanguage) ?? IsoLanguages.Get(Language.English);
var language = isoLanguage.TwoLetterCode;
if (isoLanguage.CountryCode.IsNotNullOrWhiteSpace())

View File

@@ -1,7 +1,9 @@
using System.Linq;
using System.Reflection;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Languages;
using Radarr.Http;
using Radarr.Http.REST.Attributes;
@@ -16,6 +18,18 @@ namespace Radarr.Api.V3.Config
: base(configService)
{
_configFileProvider = configFileProvider;
SharedValidator.RuleFor(c => c.UILanguage).Custom((value, context) =>
{
if (!Language.All.Any(o => o.Id == value))
{
context.AddFailure("Invalid UI Language ID");
}
});
SharedValidator.RuleFor(c => c.UILanguage)
.GreaterThanOrEqualTo(1)
.WithMessage("The UI Language value cannot be less than 1");
}
[RestPutById]