From 32d61da57a0a7f522dfd5af79bbfa29d45ff8346 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 14 Jul 2024 13:56:29 -0500 Subject: [PATCH] Localization for sleep timer modal, UI updates --- .../components/app/MediaPlayerContainer.vue | 4 +- .../components/modals/PlayerSettingsModal.vue | 12 +-- client/components/modals/SleepTimerModal.vue | 80 ++++++++++--------- .../player/PlayerPlaybackControls.vue | 4 +- client/components/player/PlayerUi.vue | 6 +- client/strings/en-us.json | 6 +- 6 files changed, 61 insertions(+), 51 deletions(-) diff --git a/client/components/app/MediaPlayerContainer.vue b/client/components/app/MediaPlayerContainer.vue index a9cdc991b8..cbc768034e 100644 --- a/client/components/app/MediaPlayerContainer.vue +++ b/client/components/app/MediaPlayerContainer.vue @@ -58,7 +58,7 @@ - + @@ -302,7 +302,7 @@ export default { } if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER && this.sleepTimerSet) { - this.checkChapterEnd(newTime) + this.checkChapterEnd(time) } }, setDuration(duration) { diff --git a/client/components/modals/PlayerSettingsModal.vue b/client/components/modals/PlayerSettingsModal.vue index 10c3cd6593..ec178d9c3a 100644 --- a/client/components/modals/PlayerSettingsModal.vue +++ b/client/components/modals/PlayerSettingsModal.vue @@ -27,12 +27,12 @@ export default { return { useChapterTrack: false, jumpValues: [ - { text: this.$getString('LabelJumpAmountSeconds', ['10']), value: 10 }, - { text: this.$getString('LabelJumpAmountSeconds', ['15']), value: 15 }, - { text: this.$getString('LabelJumpAmountSeconds', ['30']), value: 30 }, - { text: this.$getString('LabelJumpAmountSeconds', ['60']), value: 60 }, - { text: this.$getString('LabelJumpAmountMinutes', ['2']), value: 120 }, - { text: this.$getString('LabelJumpAmountMinutes', ['5']), value: 300 } + { text: this.$getString('LabelTimeDurationXSeconds', ['10']), value: 10 }, + { text: this.$getString('LabelTimeDurationXSeconds', ['15']), value: 15 }, + { text: this.$getString('LabelTimeDurationXSeconds', ['30']), value: 30 }, + { text: this.$getString('LabelTimeDurationXSeconds', ['60']), value: 60 }, + { text: this.$getString('LabelTimeDurationXMinutes', ['2']), value: 120 }, + { text: this.$getString('LabelTimeDurationXMinutes', ['5']), value: 300 } ], jumpForwardAmount: 10, jumpBackwardAmount: 10 diff --git a/client/components/modals/SleepTimerModal.vue b/client/components/modals/SleepTimerModal.vue index e1c94883a6..43b55217ac 100644 --- a/client/components/modals/SleepTimerModal.vue +++ b/client/components/modals/SleepTimerModal.vue @@ -6,37 +6,39 @@ -
+
- + Set
-
-
- +
+
+ +
+ remove - 30m + 30m - + -

{{ $secondsToTimestamp(remaining) }}

+

{{ $secondsToTimestamp(remaining) }}

- + - + add - 30m + 30m
- {{ $strings.ButtonCancel }} + {{ $strings.ButtonCancel }}
@@ -48,64 +50,70 @@ export default { value: Boolean, timerSet: Boolean, timerType: String, - remaining: Number + remaining: Number, + hasChapters: Boolean }, data() { return { - customTime: null, - sleepTimes: [ + customTime: null + } + }, + computed: { + show: { + get() { + return this.value + }, + set(val) { + this.$emit('input', val) + } + }, + sleepTimes() { + const times = [ { seconds: 60 * 5, - text: '5 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['5']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 15, - text: '15 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['15']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 20, - text: '20 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['20']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 30, - text: '30 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['30']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 45, - text: '45 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['45']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 60, - text: '60 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['60']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 90, - text: '90 minutes', + text: this.$getString('LabelTimeDurationXMinutes', ['90']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN }, { seconds: 60 * 120, - text: '2 hours', + text: this.$getString('LabelTimeDurationXHours', ['2']), timerType: this.$constants.SleepTimerTypes.COUNTDOWN - }, - { seconds: -1, text: 'End of chapter', timerType: this.$constants.SleepTimerTypes.CHAPTER } + } ] - } - }, - computed: { - show: { - get() { - return this.value - }, - set(val) { - this.$emit('input', val) + if (this.hasChapters) { + times.push({ seconds: -1, text: this.$strings.LabelEndOfChapter, timerType: this.$constants.SleepTimerTypes.CHAPTER }) } + return times } }, methods: { diff --git a/client/components/player/PlayerPlaybackControls.vue b/client/components/player/PlayerPlaybackControls.vue index 664385bde4..76397e9817 100644 --- a/client/components/player/PlayerPlaybackControls.vue +++ b/client/components/player/PlayerPlaybackControls.vue @@ -96,10 +96,10 @@ export default { let formattedTime = '' if (amount <= 60) { - formattedTime = this.$getString('LabelJumpAmountSeconds', [amount]) + formattedTime = this.$getString('LabelTimeDurationXSeconds', [amount]) } else { const minutes = Math.floor(amount / 60) - formattedTime = this.$getString('LabelJumpAmountMinutes', [minutes]) + formattedTime = this.$getString('LabelTimeDurationXMinutes', [minutes]) } return `${prefix} - ${formattedTime}` diff --git a/client/components/player/PlayerUi.vue b/client/components/player/PlayerUi.vue index ac2c1feb8d..684520618d 100644 --- a/client/components/player/PlayerUi.vue +++ b/client/components/player/PlayerUi.vue @@ -13,7 +13,7 @@ snooze
snooze -

{{ sleepTimerRemainingString }}

+

{{ sleepTimerRemainingString }}

@@ -107,14 +107,14 @@ export default { computed: { sleepTimerRemainingString() { if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER) { - return this.$strings.LabelEndOfChapter + return 'EoC' } else { var rounded = Math.round(this.sleepTimerRemaining) if (rounded < 90) { return `${rounded}s` } var minutesRounded = Math.round(rounded / 60) - if (minutesRounded < 90) { + if (minutesRounded <= 90) { return `${minutesRounded}m` } var hoursRounded = Math.round(minutesRounded / 60) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 4236a64427..a0933d4d48 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -346,8 +346,6 @@ "LabelIntervalEveryHour": "Every hour", "LabelInvert": "Invert", "LabelItem": "Item", - "LabelJumpAmountMinutes": "{0} minutes", - "LabelJumpAmountSeconds": "{0} seconds", "LabelJumpBackwardAmount": "Jump backward amount", "LabelJumpForwardAmount": "Jump forward amount", "LabelLanguage": "Language", @@ -566,6 +564,10 @@ "LabelThemeDark": "Dark", "LabelThemeLight": "Light", "LabelTimeBase": "Time Base", + "LabelTimeDurationXHours": "{0} hours", + "LabelTimeDurationXMinutes": "{0} minutes", + "LabelTimeDurationXSeconds": "{0} seconds", + "LabelTimeInMinutes": "Time in minutes", "LabelTimeListened": "Time Listened", "LabelTimeListenedToday": "Time Listened Today", "LabelTimeRemaining": "{0} remaining",