diff --git a/src/hooks/useTimer.ts b/src/hooks/useTimer.ts index 85d933e..a105ac4 100644 --- a/src/hooks/useTimer.ts +++ b/src/hooks/useTimer.ts @@ -3,6 +3,7 @@ import { StopwatchState } from '@/types/StopwatchState' import { notify } from '@/utils/notification' import { useInterval } from './useInterval' import { useWakeLock } from './useWakeLock' +import i18n from '@/i18n' const format = (num: number) => { return num.toString().padStart(2, '0') @@ -48,8 +49,8 @@ export const useTimer = () => { const dev = isDev1Turn.value ? 'Dev 1' : 'Dev 2' - notify('Change!', { - body: `${dev}, your turn!` + notify(i18n.t('notification.change.title').toString(), { + body: i18n.t('notification.change.body', { dev }).toString() }) } }, 1000) diff --git a/src/locales/en.json b/src/locales/en.json new file mode 100644 index 0000000..c34e0ec --- /dev/null +++ b/src/locales/en.json @@ -0,0 +1,12 @@ +{ + "notification": { + "update": { + "title": "An update is available!", + "body": "Reload the app to install the update." + }, + "change": { + "title": "Change!", + "body": "{dev}, your turn" + } + } +} diff --git a/src/locales/fr.json b/src/locales/fr.json new file mode 100644 index 0000000..9dbe92f --- /dev/null +++ b/src/locales/fr.json @@ -0,0 +1,12 @@ +{ + "notification": { + "update": { + "title": "Une mise à jour est disponible !", + "body": "Recharger l'application pour l'installer." + }, + "change": { + "title": "Changement !", + "body": "À votre tour {dev}." + } + } +} diff --git a/src/registerServiceWorker.ts b/src/registerServiceWorker.ts index acaae25..e3429ba 100644 --- a/src/registerServiceWorker.ts +++ b/src/registerServiceWorker.ts @@ -2,6 +2,7 @@ import { register } from 'register-service-worker' import { setNotificationInstance, notify } from './utils/notification' +import i18n from '@/i18n' if (process.env.NODE_ENV === 'production') { register(`${process.env.BASE_URL}service-worker.js`, { @@ -30,8 +31,8 @@ if (process.env.NODE_ENV === 'production') { setNotificationInstance((title, options?) => sw.showNotification(title, options) ) - notify('An update is available!', { - body: `Reload the app to install the update.`, + notify(i18n.t('notification.update.title').toString(), { + body: i18n.t('notification.update.body').toString(), tag: 'new-version' }) },