mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-01 06:50:13 +02:00
localized date-fns library
This commit is contained in:
@ -73,6 +73,8 @@ async function loadi18n(code) {
|
|||||||
for (const key in Vue.prototype.$strings) {
|
for (const key in Vue.prototype.$strings) {
|
||||||
Vue.prototype.$strings[key] = strings[key] || translations[defaultCode][key]
|
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)
|
console.log('i18n strings=', Vue.prototype.$strings)
|
||||||
Vue.prototype.$eventBus.$emit('change-lang', code)
|
Vue.prototype.$eventBus.$emit('change-lang', code)
|
||||||
|
@ -1,10 +1,26 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Path from 'path'
|
import Path from 'path'
|
||||||
import vClickOutside from 'v-click-outside'
|
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.directive('click-outside', vClickOutside.directive)
|
||||||
|
|
||||||
|
|
||||||
|
Vue.prototype.$setDateFnsLocale = (localeString) => {
|
||||||
|
if (!locale[localeString]) return 0
|
||||||
|
return setDefaultOptions({locale: locale[localeString]})
|
||||||
|
}
|
||||||
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
||||||
if (!unixms) return ''
|
if (!unixms) return ''
|
||||||
return formatDistance(unixms, Date.now(), { addSuffix: true })
|
return formatDistance(unixms, Date.now(), { addSuffix: true })
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Benutzer {0} bearbeiten",
|
"ButtonUserEdit": "Benutzer {0} bearbeiten",
|
||||||
"ButtonViewAll": "Alles anzeigen",
|
"ButtonViewAll": "Alles anzeigen",
|
||||||
"ButtonYes": "Ja",
|
"ButtonYes": "Ja",
|
||||||
|
"ConfigDateFnsLocale": "de",
|
||||||
"HeaderAccount": "Konto",
|
"HeaderAccount": "Konto",
|
||||||
"HeaderAdvanced": "Erweitert",
|
"HeaderAdvanced": "Erweitert",
|
||||||
"HeaderAppriseNotificationSettings": "Apprise Benachrichtigungseinstellungen",
|
"HeaderAppriseNotificationSettings": "Apprise Benachrichtigungseinstellungen",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Edit user {0}",
|
"ButtonUserEdit": "Edit user {0}",
|
||||||
"ButtonViewAll": "View All",
|
"ButtonViewAll": "View All",
|
||||||
"ButtonYes": "Yes",
|
"ButtonYes": "Yes",
|
||||||
|
"ConfigDateFnsLocale": "enUS",
|
||||||
"HeaderAccount": "Account",
|
"HeaderAccount": "Account",
|
||||||
"HeaderAdvanced": "Advanced",
|
"HeaderAdvanced": "Advanced",
|
||||||
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Edit user {0}",
|
"ButtonUserEdit": "Edit user {0}",
|
||||||
"ButtonViewAll": "View All",
|
"ButtonViewAll": "View All",
|
||||||
"ButtonYes": "Yes",
|
"ButtonYes": "Yes",
|
||||||
|
"ConfigDateFnsLocale": "es",
|
||||||
"HeaderAccount": "Account",
|
"HeaderAccount": "Account",
|
||||||
"HeaderAdvanced": "Advanced",
|
"HeaderAdvanced": "Advanced",
|
||||||
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Modifier l'utilisateur {0}",
|
"ButtonUserEdit": "Modifier l'utilisateur {0}",
|
||||||
"ButtonViewAll": "Afficher Tout",
|
"ButtonViewAll": "Afficher Tout",
|
||||||
"ButtonYes": "Oui",
|
"ButtonYes": "Oui",
|
||||||
|
"ConfigDateFnsLocale": "fr",
|
||||||
"HeaderAccount": "Compte",
|
"HeaderAccount": "Compte",
|
||||||
"HeaderAdvanced": "Avancé",
|
"HeaderAdvanced": "Avancé",
|
||||||
"HeaderAppriseNotificationSettings": "Configuration des Notifications Apprise",
|
"HeaderAppriseNotificationSettings": "Configuration des Notifications Apprise",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Edit user {0}",
|
"ButtonUserEdit": "Edit user {0}",
|
||||||
"ButtonViewAll": "Prikaži sve",
|
"ButtonViewAll": "Prikaži sve",
|
||||||
"ButtonYes": "Da",
|
"ButtonYes": "Da",
|
||||||
|
"ConfigDateFnsLocale": "hr",
|
||||||
"HeaderAccount": "Korisnički račun",
|
"HeaderAccount": "Korisnički račun",
|
||||||
"HeaderAdvanced": "Napredno",
|
"HeaderAdvanced": "Napredno",
|
||||||
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
"HeaderAppriseNotificationSettings": "Apprise Notification Settings",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Modifica Utente {0}",
|
"ButtonUserEdit": "Modifica Utente {0}",
|
||||||
"ButtonViewAll": "Mostra Tutto",
|
"ButtonViewAll": "Mostra Tutto",
|
||||||
"ButtonYes": "Si",
|
"ButtonYes": "Si",
|
||||||
|
"ConfigDateFnsLocale": "it",
|
||||||
"HeaderAccount": "Account",
|
"HeaderAccount": "Account",
|
||||||
"HeaderAdvanced": "Avanzate",
|
"HeaderAdvanced": "Avanzate",
|
||||||
"HeaderAppriseNotificationSettings": "Apprendi le impostazioni di Notifica",
|
"HeaderAppriseNotificationSettings": "Apprendi le impostazioni di Notifica",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "Edit user {0}",
|
"ButtonUserEdit": "Edit user {0}",
|
||||||
"ButtonViewAll": "Zobacz wszystko",
|
"ButtonViewAll": "Zobacz wszystko",
|
||||||
"ButtonYes": "Tak",
|
"ButtonYes": "Tak",
|
||||||
|
"ConfigDateFnsLocale": "pl",
|
||||||
"HeaderAccount": "Konto",
|
"HeaderAccount": "Konto",
|
||||||
"HeaderAdvanced": "Zaawansowane",
|
"HeaderAdvanced": "Zaawansowane",
|
||||||
"HeaderAppriseNotificationSettings": "Ustawienia powiadomień Apprise",
|
"HeaderAppriseNotificationSettings": "Ustawienia powiadomień Apprise",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"ButtonUserEdit": "编辑用户 {0}",
|
"ButtonUserEdit": "编辑用户 {0}",
|
||||||
"ButtonViewAll": "查看全部",
|
"ButtonViewAll": "查看全部",
|
||||||
"ButtonYes": "确定",
|
"ButtonYes": "确定",
|
||||||
|
"ConfigDateFnsLocale": "znCN",
|
||||||
"HeaderAccount": "帐户",
|
"HeaderAccount": "帐户",
|
||||||
"HeaderAdvanced": "高级",
|
"HeaderAdvanced": "高级",
|
||||||
"HeaderAppriseNotificationSettings": "测试通知设置",
|
"HeaderAppriseNotificationSettings": "测试通知设置",
|
||||||
|
Reference in New Issue
Block a user