From 19a65dba984fab9996398154ea6c3bcf29ae5184 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 21 Feb 2025 18:18:16 -0600 Subject: [PATCH] Update backup schedule description translations #4017 --- client/pages/config/backups.vue | 2 +- client/plugins/i18n.js | 14 ++++++++++++++ client/plugins/utils.js | 18 +++++++++--------- client/strings/en-us.json | 1 + 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index d1dce014..98406434 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -122,7 +122,7 @@ export default { }, scheduleDescription() { if (!this.cronExpression) return '' - const parsed = this.$parseCronExpression(this.cronExpression) + const parsed = this.$parseCronExpression(this.cronExpression, this) return parsed ? parsed.description : `${this.$strings.LabelCustomCronExpression} ${this.cronExpression}` }, nextBackupDate() { diff --git a/client/plugins/i18n.js b/client/plugins/i18n.js index 5f6b1508..1769e6eb 100644 --- a/client/plugins/i18n.js +++ b/client/plugins/i18n.js @@ -107,6 +107,19 @@ Vue.prototype.$formatNumber = (num) => { return Intl.NumberFormat(Vue.prototype.$languageCodes.current).format(num) } +/** + * Get the days of the week for the current language + * Starts with Sunday + * @returns {string[]} + */ +Vue.prototype.$getDaysOfWeek = () => { + const days = [] + for (let i = 0; i < 7; i++) { + days.push(new Date(2025, 0, 5 + i).toLocaleString(Vue.prototype.$languageCodes.current, { weekday: 'long' })) + } + return days +} + const translations = { [defaultCode]: enUsStrings } @@ -148,6 +161,7 @@ async function loadi18n(code) { Vue.prototype.$setDateFnsLocale(languageCodeMap[code].dateFnsLocale) this?.$eventBus?.$emit('change-lang', code) + return true } diff --git a/client/plugins/utils.js b/client/plugins/utils.js index 5ad909d3..96b1f31c 100644 --- a/client/plugins/utils.js +++ b/client/plugins/utils.js @@ -93,7 +93,7 @@ Vue.prototype.$elapsedPrettyExtended = (seconds, useDays = true, showSeconds = t return strs.join(' ') } -Vue.prototype.$parseCronExpression = (expression) => { +Vue.prototype.$parseCronExpression = (expression, context) => { if (!expression) return null const pieces = expression.split(' ') if (pieces.length !== 5) { @@ -102,31 +102,31 @@ Vue.prototype.$parseCronExpression = (expression) => { const commonPatterns = [ { - text: 'Every 12 hours', + text: context.$strings.LabelIntervalEvery12Hours, value: '0 */12 * * *' }, { - text: 'Every 6 hours', + text: context.$strings.LabelIntervalEvery6Hours, value: '0 */6 * * *' }, { - text: 'Every 2 hours', + text: context.$strings.LabelIntervalEvery2Hours, value: '0 */2 * * *' }, { - text: 'Every hour', + text: context.$strings.LabelIntervalEveryHour, value: '0 * * * *' }, { - text: 'Every 30 minutes', + text: context.$strings.LabelIntervalEvery30Minutes, value: '*/30 * * * *' }, { - text: 'Every 15 minutes', + text: context.$strings.LabelIntervalEvery15Minutes, value: '*/15 * * * *' }, { - text: 'Every minute', + text: context.$strings.LabelIntervalEveryMinute, value: '* * * * *' } ] @@ -147,7 +147,7 @@ Vue.prototype.$parseCronExpression = (expression) => { return null } - const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + const weekdays = context.$getDaysOfWeek() var weekdayText = 'day' if (pieces[4] !== '*') weekdayText = pieces[4] diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 3e3bfe33..8a2206a4 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -393,6 +393,7 @@ "LabelIntervalEvery6Hours": "Every 6 hours", "LabelIntervalEveryDay": "Every day", "LabelIntervalEveryHour": "Every hour", + "LabelIntervalEveryMinute": "Every minute", "LabelInvert": "Invert", "LabelItem": "Item", "LabelJumpBackwardAmount": "Jump backward amount",