localized date-fns library

This commit is contained in:
Tomazed 2023-01-30 00:52:28 +01:00
parent 030c20b12e
commit e8d582269b
10 changed files with 27 additions and 1 deletions

View File

@ -73,6 +73,8 @@ async function loadi18n(code) {
for (const key in Vue.prototype.$strings) {
Vue.prototype.$strings[key] = strings[key] || translations[defaultCode][key]
}
console.log(`ConfigDateFnsLocale = ${translations[code].ConfigDateFnsLocale}`)
Vue.prototype.$setDateFnsLocale(translations[code].ConfigDateFnsLocale)
console.log('i18n strings=', Vue.prototype.$strings)
Vue.prototype.$eventBus.$emit('change-lang', code)

View File

@ -1,10 +1,26 @@
import Vue from 'vue'
import Path from 'path'
import vClickOutside from 'v-click-outside'
import { formatDistance, format, addDays, isDate } from 'date-fns'
import { formatDistance, format, addDays, isDate, setDefaultOptions } from 'date-fns'
import { de as localeDE, enUS as localeENUS, es as localeES, fr as localeFR, hr as localeHR, it as localeIT, pl as localePL, zhCN as localeZNCN } from 'date-fns/locale'
let locale = {
de: localeDE,
enUS: localeENUS,
es: localeES,
fr: localeFR,
hr: localeHR,
it: localeIT,
pl: localePL,
znCN: localeZNCN
}
Vue.directive('click-outside', vClickOutside.directive)
Vue.prototype.$setDateFnsLocale = (localeString) => {
if (!locale[localeString]) return 0
return setDefaultOptions({locale: locale[localeString]})
}
Vue.prototype.$dateDistanceFromNow = (unixms) => {
if (!unixms) return ''
return formatDistance(unixms, Date.now(), { addSuffix: true })

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Benutzer {0} bearbeiten",
"ButtonViewAll": "Alles anzeigen",
"ButtonYes": "Ja",
"ConfigDateFnsLocale": "de",
"HeaderAccount": "Konto",
"HeaderAdvanced": "Erweitert",
"HeaderAppriseNotificationSettings": "Apprise Benachrichtigungseinstellungen",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Edit user {0}",
"ButtonViewAll": "View All",
"ButtonYes": "Yes",
"ConfigDateFnsLocale": "enUS",
"HeaderAccount": "Account",
"HeaderAdvanced": "Advanced",
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Edit user {0}",
"ButtonViewAll": "View All",
"ButtonYes": "Yes",
"ConfigDateFnsLocale": "es",
"HeaderAccount": "Account",
"HeaderAdvanced": "Advanced",
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Modifier l'utilisateur {0}",
"ButtonViewAll": "Afficher Tout",
"ButtonYes": "Oui",
"ConfigDateFnsLocale": "fr",
"HeaderAccount": "Compte",
"HeaderAdvanced": "Avancé",
"HeaderAppriseNotificationSettings": "Configuration des Notifications Apprise",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Edit user {0}",
"ButtonViewAll": "Prikaži sve",
"ButtonYes": "Da",
"ConfigDateFnsLocale": "hr",
"HeaderAccount": "Korisnički račun",
"HeaderAdvanced": "Napredno",
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Modifica Utente {0}",
"ButtonViewAll": "Mostra Tutto",
"ButtonYes": "Si",
"ConfigDateFnsLocale": "it",
"HeaderAccount": "Account",
"HeaderAdvanced": "Avanzate",
"HeaderAppriseNotificationSettings": "Apprendi le impostazioni di Notifica",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "Edit user {0}",
"ButtonViewAll": "Zobacz wszystko",
"ButtonYes": "Tak",
"ConfigDateFnsLocale": "pl",
"HeaderAccount": "Konto",
"HeaderAdvanced": "Zaawansowane",
"HeaderAppriseNotificationSettings": "Ustawienia powiadomień Apprise",

View File

@ -80,6 +80,7 @@
"ButtonUserEdit": "编辑用户 {0}",
"ButtonViewAll": "查看全部",
"ButtonYes": "确定",
"ConfigDateFnsLocale": "znCN",
"HeaderAccount": "帐户",
"HeaderAdvanced": "高级",
"HeaderAppriseNotificationSettings": "测试通知设置",