mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-03-05 13:40:08 -05:00
Fixed: Fallback to English translations if invalid UI language in config
(cherry picked from commit 4c7201741276eccaea2fb1f33daecc31e8b2d54e)
This commit is contained in:
@@ -176,6 +176,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>
|
||||
|
||||
@@ -294,6 +294,7 @@
|
||||
"InstanceNameHelpText": "Instance name in tab and for Syslog app name",
|
||||
"InteractiveSearch": "Interactive Search",
|
||||
"Interval": "Interval",
|
||||
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
|
||||
"KeyboardShortcuts": "Keyboard Shortcuts",
|
||||
"Label": "Label",
|
||||
"Language": "Language",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Http.REST.Attributes;
|
||||
using Prowlarr.Http;
|
||||
|
||||
@@ -12,10 +14,22 @@ namespace Prowlarr.Api.V1.Config
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
|
||||
public UiConfigController(IConfigFileProvider configFileProvider, IConfigService configService)
|
||||
public UiConfigController(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService)
|
||||
: base(configService)
|
||||
{
|
||||
_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]
|
||||
|
||||
Reference in New Issue
Block a user