From 594aad9d3ae9b323677f3af8c434d7664526593d Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Wed, 3 Mar 2021 18:34:21 -0500 Subject: [PATCH] feat(lang): localize job names (#1043) --- .../Settings/SettingsJobsCache/index.tsx | 37 +++++++++++++++---- src/i18n/locale/en.json | 7 ++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/components/Settings/SettingsJobsCache/index.tsx b/src/components/Settings/SettingsJobsCache/index.tsx index de725b88..0e70b6b4 100644 --- a/src/components/Settings/SettingsJobsCache/index.tsx +++ b/src/components/Settings/SettingsJobsCache/index.tsx @@ -1,7 +1,12 @@ import React from 'react'; import useSWR from 'swr'; import LoadingSpinner from '../../Common/LoadingSpinner'; -import { FormattedRelativeTime, defineMessages, useIntl } from 'react-intl'; +import { + FormattedRelativeTime, + defineMessages, + useIntl, + MessageDescriptor, +} from 'react-intl'; import Button from '../../Common/Button'; import Table from '../../Common/Table'; import Spinner from '../../../assets/spinner.svg'; @@ -11,7 +16,7 @@ import Badge from '../../Common/Badge'; import { CacheItem } from '../../../../server/interfaces/api/settingsInterfaces'; import { formatBytes } from '../../../utils/numberHelpers'; -const messages = defineMessages({ +const messages: { [messageName: string]: MessageDescriptor } = defineMessages({ jobs: 'Jobs', jobsDescription: 'Overseerr performs certain maintenance tasks as regularly-scheduled jobs, but they can also be manually triggered below. Manually running a job will not alter its schedule.', @@ -35,6 +40,13 @@ const messages = defineMessages({ cacheksize: 'Key Size', cachevsize: 'Value Size', flushcache: 'Flush Cache', + unknownJob: 'Unknown Job', + 'plex-recently-added-sync': 'Plex Recently Added Sync', + 'plex-full-sync': 'Plex Full Library Sync', + 'radarr-sync': 'Radarr Sync', + 'sonarr-sync': 'Sonarr Sync', + 'download-sync': 'Download Sync', + 'download-sync-reset': 'Download Sync Reset', }); interface Job { @@ -66,7 +78,7 @@ const SettingsJobs: React.FC = () => { await axios.post(`/api/v1/settings/jobs/${job.id}/run`); addToast( intl.formatMessage(messages.jobstarted, { - jobname: job.name, + jobname: intl.formatMessage(messages[job.id] ?? messages.unknownJob), }), { appearance: 'success', @@ -78,10 +90,15 @@ const SettingsJobs: React.FC = () => { const cancelJob = async (job: Job) => { await axios.post(`/api/v1/settings/jobs/${job.id}/cancel`); - addToast(intl.formatMessage(messages.jobcancelled, { jobname: job.name }), { - appearance: 'error', - autoDismiss: true, - }); + addToast( + intl.formatMessage(messages.jobcancelled, { + jobname: intl.formatMessage(messages[job.id] ?? messages.unknownJob), + }), + { + appearance: 'error', + autoDismiss: true, + } + ); revalidate(); }; @@ -121,7 +138,11 @@ const SettingsJobs: React.FC = () => {
{job.running && } - {job.name} + + {intl.formatMessage( + messages[job.id] ?? messages.unknownJob + )} +
diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 30cf1bb6..b16e0875 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -411,6 +411,8 @@ "components.Settings.SettingsJobsCache.cachevsize": "Value Size", "components.Settings.SettingsJobsCache.canceljob": "Cancel Job", "components.Settings.SettingsJobsCache.command": "Command", + "components.Settings.SettingsJobsCache.download-sync": "Download Sync", + "components.Settings.SettingsJobsCache.download-sync-reset": "Download Sync Reset", "components.Settings.SettingsJobsCache.flushcache": "Flush Cache", "components.Settings.SettingsJobsCache.jobcancelled": "{jobname} canceled.", "components.Settings.SettingsJobsCache.jobname": "Job Name", @@ -419,8 +421,13 @@ "components.Settings.SettingsJobsCache.jobstarted": "{jobname} started.", "components.Settings.SettingsJobsCache.jobtype": "Type", "components.Settings.SettingsJobsCache.nextexecution": "Next Execution", + "components.Settings.SettingsJobsCache.plex-full-sync": "Plex Full Library Sync", + "components.Settings.SettingsJobsCache.plex-recently-added-sync": "Plex Recently Added Sync", "components.Settings.SettingsJobsCache.process": "Process", + "components.Settings.SettingsJobsCache.radarr-sync": "Radarr Sync", "components.Settings.SettingsJobsCache.runnow": "Run Now", + "components.Settings.SettingsJobsCache.sonarr-sync": "Sonarr Sync", + "components.Settings.SettingsJobsCache.unknownJob": "Unknown Job", "components.Settings.SonarrModal.add": "Add Server", "components.Settings.SonarrModal.animelanguageprofile": "Anime Language Profile", "components.Settings.SonarrModal.animequalityprofile": "Anime Quality Profile",