diff --git a/frontend/src/Settings/UI/UISettings.js b/frontend/src/Settings/UI/UISettings.js index ed80d23fc..4918ed73b 100644 --- a/frontend/src/Settings/UI/UISettings.js +++ b/frontend/src/Settings/UI/UISettings.js @@ -248,6 +248,13 @@ class UISettings extends Component { helpTextWarning={translate('UILanguageHelpTextWarning')} onChange={onInputChange} {...settings.uiLanguage} + errors={ + languages.some((language) => language.key === settings.uiLanguage.value) ? + settings.uiLanguage.errors : + [ + ...settings.uiLanguage.errors, + { message: translate('InvalidUILanguage') } + ]} /> diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 3192e3a4d..1be966bf6 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -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", diff --git a/src/NzbDrone.Core/Localization/LocalizationService.cs b/src/NzbDrone.Core/Localization/LocalizationService.cs index 8633ea45c..d0c5c8eb7 100644 --- a/src/NzbDrone.Core/Localization/LocalizationService.cs +++ b/src/NzbDrone.Core/Localization/LocalizationService.cs @@ -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()) diff --git a/src/Radarr.Api.V3/Config/UiConfigController.cs b/src/Radarr.Api.V3/Config/UiConfigController.cs index b35b6581c..fb6310c73 100644 --- a/src/Radarr.Api.V3/Config/UiConfigController.cs +++ b/src/Radarr.Api.V3/Config/UiConfigController.cs @@ -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]