mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2024-11-26 19:59:56 +01:00
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:
parent
20686c3d82
commit
baa7b014eb
@ -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`
|
||||
|
@ -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
|
||||
|
@ -1639,7 +1639,8 @@ export default defineComponent({
|
||||
captionTracks.unshift({
|
||||
url: url.toString(),
|
||||
label,
|
||||
language_code: locale
|
||||
language_code: locale,
|
||||
is_autotranslated: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user