mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(YouTube - Translations): Patch exception thrown when the patch option String resources to keep
is empty https://github.com/inotia00/ReVanced_Extended/issues/2778
This commit is contained in:
parent
80b9f754ed
commit
0259869169
@ -118,7 +118,12 @@ fun ResourcePatchContext.baseTranslationsPatch(
|
||||
if (!isYouTube) return
|
||||
|
||||
filteredAppLanguages = filteredAppLanguages.map { language ->
|
||||
language.subSequence(0,2).toString().uppercase()
|
||||
val hyphenIndex = language.indexOf("-") - 1
|
||||
if (hyphenIndex > 2) {
|
||||
language.subSequence(0, hyphenIndex).toString().uppercase()
|
||||
} else {
|
||||
language.uppercase()
|
||||
}
|
||||
}.toHashSet().toTypedArray()
|
||||
|
||||
// Remove unselected app languages from RVX Settings
|
||||
@ -140,7 +145,9 @@ fun ResourcePatchContext.baseTranslationsPatch(
|
||||
val item = itemNodes.item(j) as? Element ?: continue
|
||||
val text = item.textContent
|
||||
val length = text.length
|
||||
if (!text.endsWith("DEFAULT") && text.subSequence(length - 2, length) !in filteredAppLanguages) {
|
||||
if (!text.endsWith("DEFAULT") &&
|
||||
length >= 2 &&
|
||||
text.subSequence(length - 2, length) !in filteredAppLanguages) {
|
||||
nodesToRemove.add(item)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user