New: Localised all health check strings

This commit is contained in:
Robin Dadswell 2021-05-07 00:21:49 +01:00
parent aa522066ee
commit d38311b717
6 changed files with 54 additions and 23 deletions

View File

@ -1,7 +1,9 @@
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Processes;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -9,6 +11,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class MonoNotNetCoreCheckFixture : CoreTest<MonoNotNetCoreCheck>
{
[SetUp]
public void setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]
[Platform(Exclude = "Mono")]
public void should_return_ok_if_net_core()

View File

@ -10,6 +10,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Parser.Model;
@ -84,6 +85,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Ensure.That(path, () => path).IsValidPath();
return false;
});
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenFolderExists(string folder)

View File

@ -50,10 +50,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (missingRootFolders.Count == 1)
{
var missingRootFolder = missingRootFolders.First();
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Missing root folder for import list(s): {FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)}", "#import_list_missing_root_folder");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ImportListMissingRoot"), FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)), "#import_list_missing_root_folder");
}
var message = string.Format("Multiple root folders are missing for import lists: {0}", string.Join(" | ", missingRootFolders.Select(m => FormatRootFolder(m.Key, m.Value))));
var message = string.Format(_localizationService.GetLocalizedString("ImportListMultipleMissingRoots"), string.Join(" | ", missingRootFolders.Select(m => FormatRootFolder(m.Key, m.Value))));
return new HealthCheck(GetType(), HealthCheckResult.Error, message, "#import_list_missing_root_folder");
}

View File

@ -69,15 +69,15 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Remote download client {client.Definition.Name} places downloads in {folder.FullPath} but this is not a valid {_osInfo.Name} path. Review your remote path mappings and download client settings.", "#bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad_remote_path_mapping");
}
else if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"You are using docker; download client {client.Definition.Name} places downloads in {folder.FullPath} but this is not a valid {_osInfo.Name} path. Review your remote path mappings and download client settings.", "#docker_bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckBadDockerPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#docker_bad_remote_path_mapping");
}
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Local download client {client.Definition.Name} places downloads in {folder.FullPath} but this is not a valid {_osInfo.Name} path. Review your download client settings.", "#bad_download_client_settings");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad_download_client_settings");
}
}
@ -85,15 +85,15 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"You are using docker; download client {client.Definition.Name} places downloads in {folder.FullPath} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.", "#docker_bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDockerFolderMissing"), client.Definition.Name, folder.FullPath), "#docker_bad_remote_path_mapping");
}
else if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Remote download client {client.Definition.Name} places downloads in {folder.FullPath} but this directory does not appear to exist. Likely missing or incorrect remote path mapping.", "#bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalFolderMissing"), client.Definition.Name, folder.FullPath), "#bad_remote_path_mapping");
}
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Download client {client.Definition.Name} places downloads in {folder.FullPath} but Radarr cannot see this directory. You may need to adjust the folder's permissions.", "#permissions_error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckGenericPermissions"), client.Definition.Name, folder.FullPath), "#permissions_error");
}
}
}
@ -130,13 +130,13 @@ namespace NzbDrone.Core.HealthCheck.Checks
var moviePath = failureMessage.MovieInfo.Path;
if (_diskProvider.FileExists(moviePath))
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Radarr can see but not access downloaded movie {moviePath}. Likely permissions error.", "#permissions_error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDownloadPermissions"), moviePath), "#permissions_error");
}
else
{
// If the file doesn't exist but MovieInfo is not null then the message is coming from
// ImportApprovedMovies and the file must have been removed part way through processing
return new HealthCheck(GetType(), HealthCheckResult.Error, $"File {moviePath} was removed part way though procesing.");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFileRemoved"), moviePath));
}
}
@ -152,43 +152,43 @@ namespace NzbDrone.Core.HealthCheck.Checks
// that the user realises something is wrong.
if (dlpath.IsNullOrWhiteSpace())
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Radarr failed to import a movie. Check your logs for details.");
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("RemotePathMappingCheckImportFailed"));
}
if (!dlpath.IsPathValid())
{
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Remote download client {client.Definition.Name} reported files in {dlpath} but this is not a valid {_osInfo.Name} path. Review your remote path mappings and download client settings.", "#bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad_remote_path_mapping");
}
else if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"You are using docker; download client {client.Definition.Name} reported files in {dlpath} but this is not a valid {_osInfo.Name} path. Review your remote path mappings and download client settings.", "#docker_bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesBadDockerPath"), client.Definition.Name, dlpath, _osInfo.Name), "#docker_bad_remote_path_mapping");
}
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Local download client {client.Definition.Name} reported files in {dlpath} but this is not a valid {_osInfo.Name} path. Review your download client settings.", "#bad_download_client_settings");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesLocalWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad_download_client_settings");
}
}
if (_diskProvider.FolderExists(dlpath))
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Radarr can see but not access download directory {dlpath}. Likely permissions error.", "#permissions_error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFolderPermissions"), dlpath), "#permissions_error");
}
// if it's a remote client/docker, likely missing path mappings
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"You are using docker; download client {client.Definition.Name} reported files in {dlpath} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.", "#docker_bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFolderPermissions"), client.Definition.Name, dlpath), "#docker_bad_remote_path_mapping");
}
else if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Remote download client {client.Definition.Name} reported files in {dlpath} but this directory does not appear to exist. Likely missing remote path mapping.", "#bad_remote_path_mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckRemoteDownloadClient"), client.Definition.Name, dlpath), "#bad_remote_path_mapping");
}
else
{
// path mappings shouldn't be needed locally so probably a permissions issue
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Download client {client.Definition.Name} reported files in {dlpath} but Radarr cannot see this directory. You may need to adjust the folder's permissions.", "#permissions_error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesGenericPermissions"), client.Definition.Name, dlpath), "#permissions_error");
}
}
catch (DownloadClientException ex)

View File

@ -68,12 +68,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
}
}
if (BuildInfo.BuildDateTime < DateTime.UtcNow.AddDays(-14))
if (BuildInfo.BuildDateTime < DateTime.UtcNow.AddDays(-14) && _checkUpdateService.AvailableUpdate() != null)
{
if (_checkUpdateService.AvailableUpdate() != null)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "New update is available");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("UpdateAvailable"));
}
return new HealthCheck(GetType());

View File

@ -394,6 +394,8 @@
"ImportIncludeQuality": "Make sure that your files include the quality in their filenames. e.g. {0}",
"Importing": "Importing",
"ImportLibrary": "Library Import",
"ImportListMissingRoot": "Missing root folder for import list(s): {0}",
"ImportListMultipleMissingRoots": "Multiple root folders are missing for import lists: {0}",
"ImportListStatusCheckAllClientMessage": "All lists are unavailable due to failures",
"ImportListStatusCheckSingleClientMessage": "Lists unavailable due to failures: {0}",
"ImportListSyncIntervalHelpText": "How often Radarr syncs with your lists. Minimum value of 6 hours",
@ -757,6 +759,22 @@
"ReleaseWillBeProcessedInterp": "Release will be processed {0}",
"Reload": "Reload",
"RemotePathMappings": "Remote Path Mappings",
"RemotePathMappingCheckBadDockerPath": "You are using docker; download client {0} places downloads in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingCheckDockerFolderMissing": "You are using docker; download client {0} places downloads in {1} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.",
"RemotePathMappingCheckLocalFolderMissing": "Remote download client {0} places downloads in {1} but this directory does not appear to exist. Likely missing or incorrect remote path mapping.",
"RemotePathMappingCheckLocalWrongOSPath": "Local download client {0} places downloads in {1} but this is not a valid {2} path. Review your download client settings.",
"RemotePathMappingCheckWrongOSPath": "Remote download client {0} places downloads in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingCheckGenericPermissions": "Download client {0} places downloads in {1} but Radarr cannot see this directory. You may need to adjust the folder's permissions.",
"RemotePathMappingCheckDownloadPermissions": "Radarr can see but not access downloaded movie {0}. Likely permissions error.",
"RemotePathMappingCheckFileRemoved": "File {0} was removed part way through processing.",
"RemotePathMappingCheckImportFailed": "Radarr failed to import a movie. Check your logs for details.",
"RemotePathMappingCheckFilesWrongOSPath": "Remote download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingCheckFilesBadDockerPath": "You are using docker; download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingCheckFilesLocalWrongOSPath": "Local download client {0} reported files in {1} but this is not a valid {2} path. Review your download client settings.",
"RemotePathMappingCheckFolderPermissions": "Radarr can see but not access download directory {0}. Likely permissions error.",
"RemotePathMappingCheckDockerFilesMissing": "You are using docker; download client {0} reported files in {1} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.",
"RemotePathMappingCheckRemoteDownloadClient": "Remote download client {0} reported files in {1} but this directory does not appear to exist. Likely missing remote path mapping.",
"RemotePathMappingCheckFilesGenericPermissions": "Download client {0} reported files in {1} but Radarr cannot see this directory. You may need to adjust the folder's permissions.",
"Remove": "Remove",
"RemoveCompletedDownloadsHelpText": "Remove imported downloads from download client history",
"RemovedFromTaskQueue": "Removed from task queue",
@ -1030,6 +1048,7 @@
"UnselectAll": "Unselect All",
"UpdateAll": "Update All",
"UpdateAutomaticallyHelpText": "Automatically download and install updates. You will still be able to install from System: Updates",
"UpdateAvailable": "New update is available",
"UpdateCheckStartupNotWritableMessage": "Cannot install update because startup folder '{0}' is not writable by the user '{1}'.",
"UpdateCheckStartupTranslocationMessage": "Cannot install update because startup folder '{0}' is in an App Translocation folder.",
"UpdateCheckUINotWritableMessage": "Cannot install update because UI folder '{0}' is not writable by the user '{1}'.",