fix: Subtitle selection not matching two letter language codes (#1805)

This commit is contained in:
Secozzi 2024-11-04 19:55:32 +01:00 committed by GitHub
parent 1b31fcad8e
commit ea2d017275
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,9 +46,11 @@ class SubtitleSelect(private val playerPreferences: PlayerPreferences) {
private fun containsLang(title: String, locale: Locale): Boolean {
val localName = locale.getDisplayName(locale)
val englishName = locale.getDisplayName(Locale.ENGLISH).substringBefore(" (")
val langRegex = Regex("""\b${locale.getISO3Language()}\b""", RegexOption.IGNORE_CASE)
val langRegex = Regex("""\b${locale.isO3Language}|${locale.language}\b""", RegexOption.IGNORE_CASE)
return title.contains(localName) || title.contains(englishName) || langRegex.find(title) != null
return title.contains(localName, true) ||
title.contains(englishName, true) ||
langRegex.find(title) != null
}
@Serializable