mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 22:07:32 -04:00
Fixed: Fallback to English translations if invalid UI language in config
(cherry picked from commit 4c7201741276eccaea2fb1f33daecc31e8b2d54e)
This commit is contained in:
parent
fab4bd5ead
commit
fc482d4808
3 changed files with 23 additions and 1 deletions
|
@ -176,6 +176,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>
|
||||||
|
|
|
@ -294,6 +294,7 @@
|
||||||
"InstanceNameHelpText": "Instance name in tab and for Syslog app name",
|
"InstanceNameHelpText": "Instance name in tab and for Syslog app name",
|
||||||
"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",
|
||||||
"KeyboardShortcuts": "Keyboard Shortcuts",
|
"KeyboardShortcuts": "Keyboard Shortcuts",
|
||||||
"Label": "Label",
|
"Label": "Label",
|
||||||
"Language": "Language",
|
"Language": "Language",
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using FluentValidation;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Localization;
|
||||||
using NzbDrone.Http.REST.Attributes;
|
using NzbDrone.Http.REST.Attributes;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
|
@ -12,10 +14,22 @@ namespace Prowlarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
private readonly IConfigFileProvider _configFileProvider;
|
private readonly IConfigFileProvider _configFileProvider;
|
||||||
|
|
||||||
public UiConfigController(IConfigFileProvider configFileProvider, IConfigService configService)
|
public UiConfigController(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService)
|
||||||
: base(configService)
|
: base(configService)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
|
|
||||||
|
SharedValidator.RuleFor(c => c.UILanguage)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("The UI Language value cannot be empty");
|
||||||
|
|
||||||
|
SharedValidator.RuleFor(c => c.UILanguage).Custom((value, context) =>
|
||||||
|
{
|
||||||
|
if (!localizationService.GetLocalizationOptions().Any(o => o.Value == value))
|
||||||
|
{
|
||||||
|
context.AddFailure("Invalid UI Language value");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[RestPutById]
|
[RestPutById]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue