mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 01:23:53 -07: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')}
|
helpTextWarning={translate('UILanguageHelpTextWarning')}
|
||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
{...settings.uiLanguage}
|
{...settings.uiLanguage}
|
||||||
|
errors={
|
||||||
|
languages.some((language) => language.key === settings.uiLanguage.value) ?
|
||||||
|
settings.uiLanguage.errors :
|
||||||
|
[
|
||||||
|
...settings.uiLanguage.errors,
|
||||||
|
{ message: translate('InvalidUILanguage') }
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</FieldSet>
|
</FieldSet>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using FluentValidation;
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.REST.Attributes;
|
using Lidarr.Http.REST.Attributes;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Languages;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
@ -16,6 +18,17 @@ namespace Lidarr.Api.V1.Config
|
||||||
: base(configService)
|
: base(configService)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_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]
|
[RestPutById]
|
||||||
|
|
|
@ -480,6 +480,7 @@
|
||||||
"InteractiveImport": "Interactive Import",
|
"InteractiveImport": "Interactive Import",
|
||||||
"InteractiveSearch": "Interactive Search",
|
"InteractiveSearch": "Interactive Search",
|
||||||
"Interval": "Interval",
|
"Interval": "Interval",
|
||||||
|
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
|
||||||
"IsCutoffCutoff": "Cutoff",
|
"IsCutoffCutoff": "Cutoff",
|
||||||
"IsCutoffUpgradeUntilThisQualityIsMetOrExceeded": "Upgrade until this quality is met or exceeded",
|
"IsCutoffUpgradeUntilThisQualityIsMetOrExceeded": "Upgrade until this quality is met or exceeded",
|
||||||
"IsExpandedHideAlbums": "Hide albums",
|
"IsExpandedHideAlbums": "Hide albums",
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace NzbDrone.Core.Localization
|
||||||
|
|
||||||
private string GetSetLanguageFileName()
|
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;
|
var language = isoLanguage.TwoLetterCode;
|
||||||
|
|
||||||
if (isoLanguage.CountryCode.IsNotNullOrWhiteSpace())
|
if (isoLanguage.CountryCode.IsNotNullOrWhiteSpace())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue