mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-12 15:03:12 +00:00
Fixed: Fallback to English translations if invalid UI language in config
(cherry picked from commit 4c7201741276eccaea2fb1f33daecc31e8b2d54e) Closes #4086
This commit is contained in:
parent
fb21dd0f19
commit
8453531a51
4 changed files with 22 additions and 1 deletions
|
@ -268,6 +268,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') }
|
||||
]}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FieldSet>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using FluentValidation;
|
||||
using Lidarr.Http;
|
||||
using Lidarr.Http.REST.Attributes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
||||
namespace Lidarr.Api.V1.Config
|
||||
{
|
||||
|
@ -16,6 +18,17 @@ namespace Lidarr.Api.V1.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 value");
|
||||
}
|
||||
});
|
||||
|
||||
SharedValidator.RuleFor(c => c.UILanguage)
|
||||
.GreaterThanOrEqualTo(1)
|
||||
.WithMessage("The UI Language value cannot be less than 1");
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
|
|
|
@ -480,6 +480,7 @@
|
|||
"InteractiveImport": "Interactive Import",
|
||||
"InteractiveSearch": "Interactive Search",
|
||||
"Interval": "Interval",
|
||||
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
|
||||
"IsCutoffCutoff": "Cutoff",
|
||||
"IsCutoffUpgradeUntilThisQualityIsMetOrExceeded": "Upgrade until this quality is met or exceeded",
|
||||
"IsExpandedHideAlbums": "Hide albums",
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace NzbDrone.Core.Localization
|
|||
|
||||
private string GetSetLanguageFileName()
|
||||
{
|
||||
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())
|
||||
|
|
Loading…
Add table
Reference in a new issue