🌐 (notification) add i18n for notif
This commit is contained in:
@@ -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)
|
||||
|
||||
12
src/locales/en.json
Normal file
12
src/locales/en.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/locales/fr.json
Normal file
12
src/locales/fr.json
Normal file
@@ -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}."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user