Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.futo.inputmethod.latin.utils
import androidx.annotation.RawRes
import org.futo.inputmethod.latin.R
import java.util.Locale
object Dictionaries {
private val dictionaries = mapOf(
"" to R.raw.main,
"de" to R.raw.main_de,
"en" to R.raw.main_en,
"es" to R.raw.main_es,
"fr" to R.raw.main_fr,
"it" to R.raw.main_it,
"pt_br" to R.raw.main_pt_br,
"ru" to R.raw.main_ru
)
@RawRes
public fun getDictionaryId(locale: Locale): Int {
var resId = 0
// Try to find main_language_country dictionary.
if (locale.country.isNotEmpty()) {
val dictLanguageCountry = locale.toString().lowercase()
resId = dictionaries[dictLanguageCountry] ?: 0
}
// Try to find main_language dictionary.
if(resId == 0) {
val dictLanguage = locale.language
resId = dictionaries[dictLanguage] ?: 0
}
return resId
}
}