From 6ffff3b4fdc06ab1a2efe2a02413d5b9670fc0a2 Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:33:46 +0300 Subject: [PATCH] fix: translate job confirm messages --- packages/ui/localesSync.config.js | 2 +- packages/ui/src/hooks/useJob.ts | 9 ++++++--- packages/ui/src/static/locales/en-US/messages.json | 14 ++++++++++++-- packages/ui/src/static/locales/fr-FR/messages.json | 13 +++++++++++-- packages/ui/src/static/locales/pt-BR/messages.json | 10 ++++++++-- packages/ui/src/static/locales/zh-CN/messages.json | 11 +++++++---- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/packages/ui/localesSync.config.js b/packages/ui/localesSync.config.js index 04215170..235adbc1 100644 --- a/packages/ui/localesSync.config.js +++ b/packages/ui/localesSync.config.js @@ -1,6 +1,6 @@ module.exports = { primaryLanguage: 'en-US', - secondaryLanguages: ['pt-BR'], + secondaryLanguages: ['pt-BR', 'fr-FR', 'zh-CN'], localesFolder: './src/static/locales', spaces: 2, }; diff --git a/packages/ui/src/hooks/useJob.ts b/packages/ui/src/hooks/useJob.ts index 1a878a3e..801ad3ee 100644 --- a/packages/ui/src/hooks/useJob.ts +++ b/packages/ui/src/hooks/useJob.ts @@ -1,4 +1,5 @@ import { AppJob, JobRetryStatus } from '@bull-board/api/typings/app'; +import { useTranslation } from 'react-i18next'; import { create } from 'zustand'; import { JobActions, Status } from '../../typings/app'; import { getConfirmFor } from '../utils/getConfirmFor'; @@ -32,6 +33,8 @@ export function useJob(): Omit & { actions: JobActions } actions: { updateQueues }, } = useQueues(); + const { t } = useTranslation(); + const { confirmJobActions, pollingInterval } = useSettingsStore( ({ confirmJobActions, pollingInterval }) => ({ confirmJobActions, @@ -53,21 +56,21 @@ export function useJob(): Omit & { actions: JobActions } const promoteJob = (queueName: string) => (job: AppJob) => withConfirmAndUpdate( () => api.promoteJob(queueName, job.id), - 'Are you sure that you want to promote this job?', + t('JOB.ACTIONS.CONFIRM.PROMOTE'), confirmJobActions ); const retryJob = (queueName: string, status: JobRetryStatus) => (job: AppJob) => withConfirmAndUpdate( () => api.retryJob(queueName, job.id, status), - 'Are you sure that you want to retry this job?', + t('JOB.ACTIONS.CONFIRM.RETRY'), confirmJobActions ); const cleanJob = (queueName: string) => (job: AppJob) => withConfirmAndUpdate( () => api.cleanJob(queueName, job.id), - 'Are you sure that you want to clean this job?', + t('JOB.ACTIONS.CONFIRM.CLEAN'), confirmJobActions ); diff --git a/packages/ui/src/static/locales/en-US/messages.json b/packages/ui/src/static/locales/en-US/messages.json index 082fbd82..3c1746c9 100644 --- a/packages/ui/src/static/locales/en-US/messages.json +++ b/packages/ui/src/static/locales/en-US/messages.json @@ -37,7 +37,12 @@ "ACTIONS": { "PROMOTE": "Promote", "CLEAN": "Clean", - "RETRY": "Retry" + "RETRY": "Retry", + "CONFIRM": { + "PROMOTE": "Are you sure that you want to promote this job?", + "RETRY": "Are you sure that you want to retry this job?", + "CLEAN": "Are you sure that you want to clean this job?" + } }, "TABS": { "DATA": "Data", @@ -79,7 +84,12 @@ "CONFIRM": { "DEFAULT_TITLE": "Are you sure?", "CONFIRM_BTN": "Confirm", - "CANCEL_BTN": "Cancel" + "CANCEL_BTN": "Cancel", + "JOB": { + "PROMOTE": "Are you sure that you want to promote this job?", + "RETRY": "Are you sure that you want to retry this job?", + "CLEAN": "Are you sure that you want to clean this job?" + } }, "MODAL": { "CLOSE_BTN": "Close" diff --git a/packages/ui/src/static/locales/fr-FR/messages.json b/packages/ui/src/static/locales/fr-FR/messages.json index acd974ea..137c869b 100644 --- a/packages/ui/src/static/locales/fr-FR/messages.json +++ b/packages/ui/src/static/locales/fr-FR/messages.json @@ -7,6 +7,8 @@ }, "DASHBOARD": { "JOBS_COUNT_one": "{{count}} Tâche", + "JOBS_COUNT_many": "{{count}} Job", + "JOBS_COUNT_other": "{{count}} Job", "JOBS_COUNT": "{{count}} Tâches" }, "JOB": { @@ -37,7 +39,12 @@ "ACTIONS": { "PROMOTE": "Promouvoir", "CLEAN": "Supprimer", - "RETRY": "Réessayer" + "RETRY": "Réessayer", + "CONFIRM": { + "PROMOTE": "Êtes-vous sûr de vouloir promouvoir ce poste ?", + "RETRY": "Êtes-vous sûr de vouloir réessayer ce poste ?", + "CLEAN": "Êtes-vous sûr de vouloir nettoyer ce poste ?" + } }, "TABS": { "DATA": "Données", @@ -107,7 +114,9 @@ "OFF": "Désactivé", "SECS": "{{count}} secondes", "MINS": "{{count}} minutes", - "MINS_one": "{{count}} minute" + "MINS_one": "{{count}} minute", + "MINS_many": "{{count}} minutes", + "MINS_other": "{{count}} minutes" }, "DEFAULT_JOB_TAB": "Onglet de tâche par défaut", "JOBS_PER_PAGE": "Tâches par page (1-50)", diff --git a/packages/ui/src/static/locales/pt-BR/messages.json b/packages/ui/src/static/locales/pt-BR/messages.json index d5a137db..2a1c5ae0 100644 --- a/packages/ui/src/static/locales/pt-BR/messages.json +++ b/packages/ui/src/static/locales/pt-BR/messages.json @@ -39,7 +39,12 @@ "ACTIONS": { "PROMOTE": "Promover", "CLEAN": "Limpar", - "RETRY": "Tente Novamente" + "RETRY": "Tente Novamente", + "CONFIRM": { + "PROMOTE": "Você tem certeza de que deseja promover este trabalho?", + "RETRY": "Você tem certeza de que deseja tentar novamente este trabalho?", + "CLEAN": "Você tem certeza de que deseja limpar este trabalho?" + } }, "TABS": { "DATA": "Dados", @@ -58,6 +63,7 @@ "RESUME": "Resumir", "PAUSE": "Pausar", "EMPTY": "Limpar", + "ADD_JOB": "Adicionar trabalho", "RETRY_ALL_CONFIRM_MSG": "Deseja realmente reprocessar todos as {{status}} tarefas?", "CLEAN_ALL_CONFIRM_MSG": "Deseja realmente limpar todos as {{status}} tarefas?", "PROMOTE_ALL_CONFIRM_MSG": "Deseja realmente promover todas as tarefas atrasadas?", @@ -129,4 +135,4 @@ "JOB_OPTIONS": "Opções da tarefa", "ADD": "Adicionar" } -} \ No newline at end of file +} diff --git a/packages/ui/src/static/locales/zh-CN/messages.json b/packages/ui/src/static/locales/zh-CN/messages.json index 6ddf2134..d5321ba5 100644 --- a/packages/ui/src/static/locales/zh-CN/messages.json +++ b/packages/ui/src/static/locales/zh-CN/messages.json @@ -6,7 +6,6 @@ "PAUSED": "已暂停" }, "DASHBOARD": { - "JOBS_COUNT_one": "{{count}} 个作业", "JOBS_COUNT": "{{count}} 个作业" }, "JOB": { @@ -37,7 +36,12 @@ "ACTIONS": { "PROMOTE": "提升", "CLEAN": "清理", - "RETRY": "重试" + "RETRY": "重试", + "CONFIRM": { + "PROMOTE": "您确定要推广这项工作吗?", + "RETRY": "您确定要重试这项工作吗?", + "CLEAN": "您确定要清理这项工作吗?" + } }, "TABS": { "DATA": "数据", @@ -106,8 +110,7 @@ "POLLING_OPTIONS": { "OFF": "关闭", "SECS": "{{count}} 秒", - "MINS": "{{count}} 分钟", - "MINS_one": "{{count}} 分钟" + "MINS": "{{count}} 分钟" }, "DEFAULT_JOB_TAB": "默认作业选项卡", "JOBS_PER_PAGE": "每页作业数量(1-50)",