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 = () => {