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
This commit is contained in:
Jason 2024-01-06 10:25:16 +00:00 committed by GitHub
parent 20686c3d82
commit baa7b014eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -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`

View File

@ -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

View File

@ -1639,7 +1639,8 @@ export default defineComponent({
captionTracks.unshift({
url: url.toString(),
label,
language_code: locale
language_code: locale,
is_autotranslated: true
})
}
},