From baa7b014ebf6ecf5838389034ad47084386c3389 Mon Sep 17 00:00:00 2001 From: Jason <84899178+jasonhenriquez@users.noreply.github.com> Date: Sat, 6 Jan 2024 10:25:16 +0000 Subject: [PATCH] Fix caption sorting & label (#4513) * Fix auto-translated captions not being ordered properly in non-English languages * Fix locale showing as 'locale name' in captions list --- _scripts/ProcessLocalesPlugin.js | 4 ---- .../components/ft-video-player/ft-video-player.js | 8 ++++++++ src/renderer/views/Watch/Watch.js | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/_scripts/ProcessLocalesPlugin.js b/_scripts/ProcessLocalesPlugin.js index 4b525fdc8..e79345e10 100644 --- a/_scripts/ProcessLocalesPlugin.js +++ b/_scripts/ProcessLocalesPlugin.js @@ -68,10 +68,6 @@ class ProcessLocalesPlugin { } } - if (Object.prototype.hasOwnProperty.call(data, 'Locale Name')) { - delete data['Locale Name'] - } - this.removeEmptyValues(data) let filename = `${this.outputDir}/${locale}.json` diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 36b010d00..a3e7f19da 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -1832,6 +1832,8 @@ export default defineComponent({ const bCode = captionB.language_code.split('-') const aName = (captionA.label) // ex: english (auto-generated) const bName = (captionB.label) + const aIsAutotranslated = captionA.is_autotranslated + const bIsAutotranslated = captionB.is_autotranslated const userLocale = this.currentLocale.split('-') // ex. [en,US] if (aCode[0] === userLocale[0]) { // caption a has same language as user's locale if (bCode[0] === userLocale[0]) { // caption b has same language as user's locale @@ -1841,6 +1843,12 @@ export default defineComponent({ } else if (aName.search('auto') !== -1) { // prefer caption b: a is auto-generated captions return 1 + } else if (bIsAutotranslated) { + // prefer caption a: b is auto-translated captions + return -1 + } else if (aIsAutotranslated) { + // prefer caption b: a is auto-translated captions + return 1 } else if (aCode[1] === userLocale[1]) { // prefer caption a: caption a has same county code as user's locale return -1 diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index d449847f0..f96bbafa4 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -1639,7 +1639,8 @@ export default defineComponent({ captionTracks.unshift({ url: url.toString(), label, - language_code: locale + language_code: locale, + is_autotranslated: true }) } },