use constant to define "good" language match

This commit is contained in:
Helium314 2024-04-11 18:22:45 +02:00
parent 159fd55695
commit 58f98e3024
2 changed files with 3 additions and 1 deletions

View file

@ -56,6 +56,8 @@ object LocaleUtils {
// The compared locales are fully identical. This is the best match level.
private const val LOCALE_FULL_MATCH = 30
const val LOCALE_GOOD_MATCH = LOCALE_LANGUAGE_MATCH_COUNTRY_DIFFER;
/**
* Return how well a tested locale matches a reference locale.
*

View file

@ -76,7 +76,7 @@ fun createDictionaryTextHtml(message: String, locale: Locale, context: Context):
// ideally the repo would switch to language tag, but not sure how this is handled in the dictionary header
// further, the dicts in the dictionaries repo should be compatible with other AOSP-based keyboards
val dictLocale = localeString.constructLocale()
if (LocaleUtils.getMatchLevel(locale, dictLocale) < 3) return@forEachLine
if (LocaleUtils.getMatchLevel(locale, dictLocale) < LocaleUtils.LOCALE_GOOD_MATCH) return@forEachLine
val rawDictString = "$type: ${dictLocale.getDisplayName(context.resources.configuration.locale())}"
val dictString = if (experimental.isEmpty()) rawDictString
else context.getString(R.string.available_dictionary_experimental, rawDictString)