diff --git a/client/components/stats/DailyListeningChart.vue b/client/components/stats/DailyListeningChart.vue index cb66668a..fda6ed89 100644 --- a/client/components/stats/DailyListeningChart.vue +++ b/client/components/stats/DailyListeningChart.vue @@ -108,7 +108,7 @@ export default { var _date = this.$addDaysToToday(i * -1) days.push({ dayOfWeek: this.$formatJsDate(_date, 'EEEE'), - dayOfWeekAbbr: this.$strings[`Weekday${this.$formatJsDate(_date, 'EEE')}`], + dayOfWeekAbbr: this.$formatJsDate(_date, 'EEE'), date: this.$formatJsDate(_date, 'yyyy-MM-dd') }) } diff --git a/client/components/stats/Heatmap.vue b/client/components/stats/Heatmap.vue index fb6f5482..7ad71f1a 100644 --- a/client/components/stats/Heatmap.vue +++ b/client/components/stats/Heatmap.vue @@ -68,7 +68,7 @@ export default { dayLabels() { return [ { - label: this.$strings.WeekdayMon, + label: this.$formatJsDate(new Date(2023, 0, 2), 'EEE'), style: { transform: `translate(${-25}px, ${13}px)`, lineHeight: '10px', @@ -76,7 +76,7 @@ export default { } }, { - label: this.$strings.WeekdayWed, + label: this.$formatJsDate(new Date(2023, 0, 4), 'EEE'), style: { transform: `translate(${-25}px, ${13 * 3}px)`, lineHeight: '10px', @@ -84,7 +84,7 @@ export default { } }, { - label: this.$strings.WeekdayFri, + label: this.$formatJsDate(new Date(2023, 0, 6), 'EEE'), style: { transform: `translate(${-25}px, ${13 * 5}px)`, lineHeight: '10px', @@ -208,7 +208,7 @@ export default { const date = i === 0 ? this.firstWeekStart : this.$addDaysToDate(this.firstWeekStart, i) const dateString = this.$formatJsDate(date, 'yyyy-MM-dd') const datePretty = this.$formatJsDate(date, 'MMM d, yyyy') - const monthString = this.$strings[`Month${this.$formatJsDate(date, 'MMM')}`] + const monthString = this.$formatJsDate(date, 'MMM') const value = this.daysListening[dateString] || 0 const x = col * 13 const y = row * 13 diff --git a/client/components/widgets/CronExpressionBuilder.vue b/client/components/widgets/CronExpressionBuilder.vue index f9c11c67..3997a0f3 100644 --- a/client/components/widgets/CronExpressionBuilder.vue +++ b/client/components/widgets/CronExpressionBuilder.vue @@ -137,31 +137,31 @@ export default { weekdays() { return [ { - text: this.$strings.WeekdaySunday, + text: this.$formatJsDate(new Date(2023, 0, 1), 'EEEE'), value: 0 }, { - text: this.$strings.WeekdayMonday, + text: this.$formatJsDate(new Date(2023, 0, 2), 'EEEE'), value: 1 }, { - text: this.$strings.WeekdayTuesday, + text: this.$formatJsDate(new Date(2023, 0, 3), 'EEEE'), value: 2 }, { - text: this.$strings.WeekdayWednesday, + text: this.$formatJsDate(new Date(2023, 0, 4), 'EEEE'), value: 3 }, { - text: this.$strings.WeekdayThursday, + text: this.$formatJsDate(new Date(2023, 0, 5), 'EEEE'), value: 4 }, { - text: this.$strings.WeekdayFriday, + text: this.$formatJsDate(new Date(2023, 0, 6), 'EEEE'), value: 5 }, { - text: this.$strings.WeekdaySaturday, + text: this.$formatJsDate(new Date(2023, 0, 7), 'EEEE'), value: 6 } ] diff --git a/client/plugins/i18n.js b/client/plugins/i18n.js index bd8015f3..3817a2c5 100644 --- a/client/plugins/i18n.js +++ b/client/plugins/i18n.js @@ -5,18 +5,18 @@ import { supplant } from './utils' const defaultCode = 'en-us' const languageCodeMap = { - 'de': 'Deutsch', - 'en-us': 'English', - // 'es': 'Español', - 'fr': 'Français', - 'hr': 'Hrvatski', - 'it': 'Italiano', - 'pl': 'Polski', - 'zh-cn': '简体中文 (Simplified Chinese)' + 'de': { label: 'Deutsch', dateFnsLocale: 'de' }, + 'en-us': { label: 'English', dateFnsLocale: 'enUS' }, + // 'es': { label: 'Español', dateFnsLocale: 'es' }, + 'fr': { label: 'Français', dateFnsLocale: 'fr' }, + 'hr': { label: 'Hrvatski', dateFnsLocale: 'hr' }, + 'it': { label: 'Italiano', dateFnsLocale: 'it' }, + 'pl': { label: 'Polski', dateFnsLocale: 'pl' }, + 'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'zhCN' }, } Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => { return { - text: languageCodeMap[code], + text: languageCodeMap[code].label, value: code } }) @@ -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(`dateFnsLocale = ${languageCodeMap[code].dateFnsLocale}`) + Vue.prototype.$setDateFnsLocale(languageCodeMap[code].dateFnsLocale) console.log('i18n strings=', Vue.prototype.$strings) Vue.prototype.$eventBus.$emit('change-lang', code) diff --git a/client/plugins/init.client.js b/client/plugins/init.client.js index 86aae006..553d9b2e 100644 --- a/client/plugins/init.client.js +++ b/client/plugins/init.client.js @@ -1,10 +1,16 @@ 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 * as locale from 'date-fns/locale' 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 }) diff --git a/client/strings/de.json b/client/strings/de.json index 0996bfdf..96b2863d 100644 --- a/client/strings/de.json +++ b/client/strings/de.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} Bibliothek ist leer!", "MessageYourAudiobookDurationIsLonger": "Die Dauer Ihres Mediums ist länger als die gefundene Dauer", "MessageYourAudiobookDurationIsShorter": "Die Dauer Ihres Mediums ist kürzer als die gefundene Dauer", - "MonthApr": "Apr", - "MonthAug": "Aug", - "MonthDec": "Dec", - "MonthFeb": "Feb", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jun", - "MonthMar": "Mar", - "MonthMay": "May", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "Der Root-Benutzer (Hauptbenutzer) ist der einzige Benutzer, der ein leeres Passwort haben kann", "NoteChapterEditorTimes": "Hinweis: Die Anfangszeit des ersten Kapitels muss bei 0:00 beginnen und die Anfangszeit des letzten Kapitels darf die Dauer des Mediums nicht überschreiten.", "NoteFolderPicker": "Hinweis: Bereits zugeordnete Ordner werden nicht angezeigt.", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Verbindung zum WebSocket verloren", "ToastSocketFailedToConnect": "Verbindung zum WebSocket fehlgeschlagen", "ToastUserDeleteFailed": "Benutzer konnte nicht gelöscht werden", - "ToastUserDeleteSuccess": "Benutzer gelöscht", - "WeekdayFri": "Fri", - "WeekdayFriday": "Freitag", - "WeekdayMon": "Mon", - "WeekdayMonday": "Montag", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Samstag", - "WeekdaySun": "Sun", - "WeekdaySunday": "Sonntag", - "WeekdayThu": "Thu", - "WeekdayThursday": "Donnerstag", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Dienstag", - "WeekdayWed": "Wed", - "WeekdayWednesday": "Mittwoch" + "ToastUserDeleteSuccess": "Benutzer gelöscht" } \ No newline at end of file diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 85ebac07..ecbd7f32 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} Library is empty!", "MessageYourAudiobookDurationIsLonger": "Your audiobook duration is longer than the duration found", "MessageYourAudiobookDurationIsShorter": "Your audiobook duration is shorter than duration found", - "MonthApr": "Apr", - "MonthAug": "Aug", - "MonthDec": "Dec", - "MonthFeb": "Feb", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jun", - "MonthMar": "Mar", - "MonthMay": "May", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "Root user is the only user that can have an empty password", "NoteChapterEditorTimes": "Note: First chapter start time must remain at 0:00 and the last chapter start time cannot exceed this audiobooks duration.", "NoteFolderPicker": "Note: folders already mapped will not be shown", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Socket disconnected", "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Failed to delete user", - "ToastUserDeleteSuccess": "User deleted", - "WeekdayFri": "Fri", - "WeekdayFriday": "Friday", - "WeekdayMon": "Mon", - "WeekdayMonday": "Monday", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Saturday", - "WeekdaySun": "Sun", - "WeekdaySunday": "Sunday", - "WeekdayThu": "Thu", - "WeekdayThursday": "Thursday", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Tuesday", - "WeekdayWed": "Wed", - "WeekdayWednesday": "Wednesday" + "ToastUserDeleteSuccess": "User deleted" } \ No newline at end of file diff --git a/client/strings/es.json b/client/strings/es.json index 85ebac07..ecbd7f32 100644 --- a/client/strings/es.json +++ b/client/strings/es.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} Library is empty!", "MessageYourAudiobookDurationIsLonger": "Your audiobook duration is longer than the duration found", "MessageYourAudiobookDurationIsShorter": "Your audiobook duration is shorter than duration found", - "MonthApr": "Apr", - "MonthAug": "Aug", - "MonthDec": "Dec", - "MonthFeb": "Feb", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jun", - "MonthMar": "Mar", - "MonthMay": "May", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "Root user is the only user that can have an empty password", "NoteChapterEditorTimes": "Note: First chapter start time must remain at 0:00 and the last chapter start time cannot exceed this audiobooks duration.", "NoteFolderPicker": "Note: folders already mapped will not be shown", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Socket disconnected", "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Failed to delete user", - "ToastUserDeleteSuccess": "User deleted", - "WeekdayFri": "Fri", - "WeekdayFriday": "Friday", - "WeekdayMon": "Mon", - "WeekdayMonday": "Monday", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Saturday", - "WeekdaySun": "Sun", - "WeekdaySunday": "Sunday", - "WeekdayThu": "Thu", - "WeekdayThursday": "Thursday", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Tuesday", - "WeekdayWed": "Wed", - "WeekdayWednesday": "Wednesday" + "ToastUserDeleteSuccess": "User deleted" } \ No newline at end of file diff --git a/client/strings/fr.json b/client/strings/fr.json index c4a0e82a..a3b5716c 100644 --- a/client/strings/fr.json +++ b/client/strings/fr.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "La Bibliothèque {0} est vide!", "MessageYourAudiobookDurationIsLonger": "La durée de votre Livre Audio est plus longue que la durée trouvée", "MessageYourAudiobookDurationIsShorter": "La durée de votre Livre Audio est plus courte que la durée trouvée", - "MonthApr": "Avr", - "MonthAug": "Aoû", - "MonthDec": "Déc", - "MonthFeb": "Fév", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jui", - "MonthMar": "Mar", - "MonthMay": "Mai", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "L'utilisateur Root est le seul a pouvoir utiliser un mote de passe vide", "NoteChapterEditorTimes": "Information: L'horodatage du premier chapitre doit être à 0:00 et celui du dernier chapitre ne peut se situer au-delà de la durée du Livre Audio.", "NoteFolderPicker": "Information: Les dossiers déjà surveillés ne sont pas affichés", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "WebSocket déconnecté", "ToastSocketFailedToConnect": "Échec de la connexion WebSocket", "ToastUserDeleteFailed": "Échec de la suppression de l'utilisateur", - "ToastUserDeleteSuccess": "Utilisateur supprimé", - "WeekdayFri": "Ven", - "WeekdayFriday": "Vendredi", - "WeekdayMon": "Lun", - "WeekdayMonday": "Lundi", - "WeekdaySat": "Sam", - "WeekdaySaturday": "Samedi", - "WeekdaySun": "Dim", - "WeekdaySunday": "Dimanche", - "WeekdayThu": "Jeu", - "WeekdayThursday": "Jeudi", - "WeekdayTue": "Mar", - "WeekdayTuesday": "Mardi", - "WeekdayWed": "Mer", - "WeekdayWednesday": "Mercredi" + "ToastUserDeleteSuccess": "Utilisateur supprimé" } \ No newline at end of file diff --git a/client/strings/hr.json b/client/strings/hr.json index cc001653..697e0d6d 100644 --- a/client/strings/hr.json +++ b/client/strings/hr.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} Library is empty!", "MessageYourAudiobookDurationIsLonger": "Trajanje audio knjige je duže nego pronadeđna duljina trajanja", "MessageYourAudiobookDurationIsShorter": "Trajanje audio knjige je kraća nego pronadeđna duljina trajanja", - "MonthApr": "Apr", - "MonthAug": "Aug", - "MonthDec": "Dec", - "MonthFeb": "Feb", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jun", - "MonthMar": "Mar", - "MonthMay": "May", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "Root korisnik je jedini korisnik koji može imati praznu lozinku", "NoteChapterEditorTimes": "Bilješka: Prvo početno vrijeme poglavlja mora ostati na 0:00 i posljednje vrijeme poglavlja ne smije preći vrijeme trajanja ove audio knjige.", "NoteFolderPicker": "Bilješka: več mapirani folderi neće biti prikazani", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Socket disconnected", "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Neuspješno brisanje korisnika", - "ToastUserDeleteSuccess": "Korisnik obrisan", - "WeekdayFri": "Fri", - "WeekdayFriday": "Petak", - "WeekdayMon": "Mon", - "WeekdayMonday": "Ponedjeljak", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Subota", - "WeekdaySun": "Sun", - "WeekdaySunday": "Nedjelja", - "WeekdayThu": "Thu", - "WeekdayThursday": "Četvrtak", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Utorak", - "WeekdayWed": "Wed", - "WeekdayWednesday": "Srijeda" + "ToastUserDeleteSuccess": "Korisnik obrisan" } \ No newline at end of file diff --git a/client/strings/it.json b/client/strings/it.json index f7d5edc5..4401cc45 100644 --- a/client/strings/it.json +++ b/client/strings/it.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} libreria vuota!", "MessageYourAudiobookDurationIsLonger": "La durata dell'audiolibro è più lunga della durata trovata", "MessageYourAudiobookDurationIsShorter": "La durata dell'audiolibro è inferiore alla durata trovata", - "MonthApr": "Apr", - "MonthAug": "Ago", - "MonthDec": "Dic", - "MonthFeb": "Feb", - "MonthJan": "Gen", - "MonthJul": "Lul", - "MonthJun": "Giu", - "MonthMar": "Mar", - "MonthMay": "Mag", - "MonthNov": "Nov", - "MonthOct": "Ott", - "MonthSep": "Set", "NoteChangeRootPassword": "L'utente root è l'unico utente che può avere una password vuota", "NoteChapterEditorTimes": "Nota: l'ora di inizio del primo capitolo deve rimanere alle 0:00 e l'ora di inizio dell'ultimo capitolo non può superare la durata di questo audiolibro.", "NoteFolderPicker": "Nota: le cartelle già mappate non verranno visualizzate", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Socket disconnesso", "ToastSocketFailedToConnect": "Socket non riesce a connettersi", "ToastUserDeleteFailed": "Errore eliminazione utente", - "ToastUserDeleteSuccess": "Utente eliminato", - "WeekdayFri": "Ven", - "WeekdayFriday": "Venerdì", - "WeekdayMon": "Lun", - "WeekdayMonday": "Lunedì", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Sabato", - "WeekdaySun": "Sun", - "WeekdaySunday": "Domenica", - "WeekdayThu": "Thu", - "WeekdayThursday": "Giovedì", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Martedì", - "WeekdayWed": "Mer", - "WeekdayWednesday": "Mercoledì" + "ToastUserDeleteSuccess": "Utente eliminato" } \ No newline at end of file diff --git a/client/strings/pl.json b/client/strings/pl.json index 5edd523f..2fb7b14a 100644 --- a/client/strings/pl.json +++ b/client/strings/pl.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} Biblioteka jest pusta!", "MessageYourAudiobookDurationIsLonger": "Czas trwania Twojego audiobooka jest dłuższy niż znaleziony czas trwania", "MessageYourAudiobookDurationIsShorter": "Czas trwania Twojego audiobooka jest krótszy niż znaleziony czas trwania", - "MonthApr": "Apr", - "MonthAug": "Aug", - "MonthDec": "Dec", - "MonthFeb": "Feb", - "MonthJan": "Jan", - "MonthJul": "Jul", - "MonthJun": "Jun", - "MonthMar": "Mar", - "MonthMay": "May", - "MonthNov": "Nov", - "MonthOct": "Oct", - "MonthSep": "Sep", "NoteChangeRootPassword": "Tylko użytkownik root, może posiadać puste hasło", "NoteChapterEditorTimes": "Uwaga: Czas rozpoczęcia pierwszego rozdziału musi pozostać na poziomie 0:00, a czas rozpoczęcia ostatniego rozdziału nie może przekroczyć czasu trwania audiobooka.", "NoteFolderPicker": "Uwaga: dotychczas zmapowane foldery nie zostaną wyświetlone", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "Połączenie z serwerem zostało zamknięte", "ToastSocketFailedToConnect": "Poączenie z serwerem nie powiodło się", "ToastUserDeleteFailed": "Nie udało się usunąć użytkownika", - "ToastUserDeleteSuccess": "Użytkownik usunięty", - "WeekdayFri": "Fri", - "WeekdayFriday": "Piątek", - "WeekdayMon": "Mon", - "WeekdayMonday": "Poniedziałek", - "WeekdaySat": "Sat", - "WeekdaySaturday": "Sobota", - "WeekdaySun": "Sun", - "WeekdaySunday": "Niedziela", - "WeekdayThu": "Thu", - "WeekdayThursday": "Czwartek", - "WeekdayTue": "Tue", - "WeekdayTuesday": "Wtorek", - "WeekdayWed": "Wed", - "WeekdayWednesday": "Środa" + "ToastUserDeleteSuccess": "Użytkownik usunięty" } \ No newline at end of file diff --git a/client/strings/zh-cn.json b/client/strings/zh-cn.json index 8e511d9b..cc6581bc 100644 --- a/client/strings/zh-cn.json +++ b/client/strings/zh-cn.json @@ -533,18 +533,6 @@ "MessageXLibraryIsEmpty": "{0} 库为空!", "MessageYourAudiobookDurationIsLonger": "您的有声读物持续时间比找到的持续时间长", "MessageYourAudiobookDurationIsShorter": "您的有声读物持续时间比找到的持续时间短", - "MonthApr": "四月", - "MonthAug": "八月", - "MonthDec": "十二月", - "MonthFeb": "二月", - "MonthJan": "一月", - "MonthJul": "七月", - "MonthJun": "六月", - "MonthMar": "三月", - "MonthMay": "五月", - "MonthNov": "十一月", - "MonthOct": "十月", - "MonthSep": "九月", "NoteChangeRootPassword": "Root 是唯一可以拥有空密码的用户", "NoteChapterEditorTimes": "注意: 第一章开始时间必须保持在 0:00, 最后一章开始时间不能超过有声读物持续时间.", "NoteFolderPicker": "注意: 将不显示已映射的文件夹", @@ -626,19 +614,5 @@ "ToastSocketDisconnected": "网络已断开", "ToastSocketFailedToConnect": "网络连接失败", "ToastUserDeleteFailed": "删除用户失败", - "ToastUserDeleteSuccess": "用户已删除", - "WeekdayFri": "周五", - "WeekdayFriday": "星期五", - "WeekdayMon": "周一", - "WeekdayMonday": "星期一", - "WeekdaySat": "周六", - "WeekdaySaturday": "星期六", - "WeekdaySun": "周日", - "WeekdaySunday": "星期日", - "WeekdayThu": "周四", - "WeekdayThursday": "星期四", - "WeekdayTue": "周二", - "WeekdayTuesday": "星期二", - "WeekdayWed": "周三", - "WeekdayWednesday": "星期三" + "ToastUserDeleteSuccess": "用户已删除" } \ No newline at end of file