mirror of
https://github.com/florisboard/florisboard.git
synced 2024-09-19 19:42:20 +02:00
Rework spell checker config and add utility script
This commit is contained in:
parent
7d8036fe69
commit
936b177776
@ -26,11 +26,17 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.ime.core.DisplayLanguageNamesIn
|
||||
import dev.patrickgold.florisboard.lib.android.showLongToast
|
||||
import dev.patrickgold.florisboard.lib.compose.FlorisIconButton
|
||||
import dev.patrickgold.florisboard.lib.compose.FlorisScreen
|
||||
import dev.patrickgold.florisboard.lib.compose.stringRes
|
||||
import dev.patrickgold.florisboard.lib.io.subDir
|
||||
import dev.patrickgold.florisboard.lib.io.subFile
|
||||
import dev.patrickgold.jetpref.datastore.model.observeAsState
|
||||
import java.util.*
|
||||
|
||||
@ -39,8 +45,38 @@ fun AndroidLocalesScreen() = FlorisScreen {
|
||||
title = stringRes(R.string.devtools__android_locales__title)
|
||||
scrollable = false
|
||||
|
||||
val context = LocalContext.current
|
||||
val availableLocales = remember { Locale.getAvailableLocales().sortedBy { it.toLanguageTag() } }
|
||||
|
||||
actions {
|
||||
FlorisIconButton(
|
||||
onClick = {
|
||||
try {
|
||||
val devtoolsDir = context.noBackupFilesDir.subDir("devtools")
|
||||
devtoolsDir.mkdirs()
|
||||
val txtFile = devtoolsDir.subFile("system_locales.tsv")
|
||||
txtFile.bufferedWriter().use { out ->
|
||||
for (locale in availableLocales) {
|
||||
out.append(locale.toLanguageTag())
|
||||
out.append('\t')
|
||||
out.append(locale.getDisplayName(Locale.ENGLISH))
|
||||
out.append('\t')
|
||||
out.append(locale.getDisplayName(locale))
|
||||
out.appendLine()
|
||||
}
|
||||
}
|
||||
context.showLongToast("Exported available system locales to \"${txtFile.path}\"")
|
||||
} catch (e: Exception) {
|
||||
context.showLongToast(
|
||||
R.string.error__snackbar_message_template,
|
||||
"error_message" to e.message.toString(),
|
||||
)
|
||||
}
|
||||
},
|
||||
icon = painterResource(R.drawable.ic_save),
|
||||
)
|
||||
}
|
||||
|
||||
content {
|
||||
val displayLanguageNamesIn by prefs.localization.displayLanguageNamesIn.observeAsState()
|
||||
|
||||
|
@ -1,6 +1,211 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Auto-generated by "utils/generate_spellcheck_config.py" on Android 11 (API 30) - DO NOT EDIT BY HAND!! -->
|
||||
<!-- Last update: 2022-06-27T22:42:38 -->
|
||||
<spell-checker xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:label="@string/floris_app_name"
|
||||
android:settingsActivity="dev.patrickgold.florisboard.SettingsLauncherAlias">
|
||||
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="af"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="agq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ak"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="am"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ar"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="as"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="asa"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ast"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="az"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bas"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="be"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bem"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bez"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bm"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="br"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="brx"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="bs"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ca"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ccp"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ce"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ceb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="cgg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="chr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ckb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="cs"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="cy"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="da"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dav"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="de"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dje"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dsb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dua"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dyo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="dz"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ebu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ee"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="el"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="en"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="eo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="es"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="et"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="eu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ewo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fa"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ff"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fil"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fur"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="fy"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ga"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="gd"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="gl"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="gsw"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="gu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="guz"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="gv"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ha"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="haw"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="he"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="hi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="hr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="hsb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="hu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="hy"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ia"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="id"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ig"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ii"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="is"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="it"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ja"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="jgo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="jmc"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="jv"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ka"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kab"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kam"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kde"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kea"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="khq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ki"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kkj"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kl"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kln"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="km"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ko"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kok"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ks"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ksb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ksf"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ksh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ku"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="kw"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ky"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lag"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lkt"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ln"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lrc"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lt"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="luo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="luy"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="lv"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mas"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mer"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mfe"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mgh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mgo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ml"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ms"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mt"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mua"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="my"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="mzn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="naq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nb"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nd"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nds"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ne"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nl"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nmg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nnh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nus"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="nyn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="om"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="or"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="os"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="pa"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="pl"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ps"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="pt"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="qu"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="rm"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="rn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ro"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="rof"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ru"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="rw"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="rwk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sah"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="saq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sbp"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sd"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="se"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="seh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ses"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="shi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="si"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sl"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="smn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sn"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="so"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sv"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="sw"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ta"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="te"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="teo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="tg"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="th"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ti"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="tk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="to"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="tr"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="tt"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="twq"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="tzm"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ug"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="uk"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="ur"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="uz"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="vai"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="vi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="vun"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="wae"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="wo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="xh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="xog"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="yav"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="yi"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="yo"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="yue"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="zgh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="zh"/>
|
||||
<subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="zu"/>
|
||||
</spell-checker>
|
||||
|
82
utils/generate_spellcheck_config.py
Normal file
82
utils/generate_spellcheck_config.py
Normal file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3.10
|
||||
# encoding: utf-8
|
||||
|
||||
"""generate_spellcheck_config.py: Simple helper script for auto generating the spell check config
|
||||
|
||||
The reason why we need to do this is because we want the language to be chosen dynamically based on the active
|
||||
keyboard subtype, and Android ignores the FlorisBoard spell checker unless it declares the currently active system
|
||||
language. As such we take the list of languages from an emulated or physical device and generate a spell checker
|
||||
config with subtypes for all languages.
|
||||
|
||||
Before running this script, make sure that exactly one device is connected and that FlorisBoard Debug (0.4.0-alpha1
|
||||
or newer) is installed. Then go to Settings > Devtools > System locales and tap the save icon in the top right
|
||||
corner. This creates a tsv file with all the devices in the interal app storage, which this script can now read.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
PULL_CMD = "adb shell".encode("utf-8")
|
||||
PULL_CMD_INPUT = """run-as dev.patrickgold.florisboard.debug
|
||||
cat no_backup/devtools/system_locales.tsv
|
||||
exit""".encode("utf-8")
|
||||
|
||||
GET_ANDROID_VERSION_CMP = "adb shell getprop ro.build.version.release".encode("utf-8")
|
||||
GET_SDK_VERSION_CMP = "adb shell getprop ro.build.version.sdk".encode("utf-8")
|
||||
|
||||
XML_CONFIG_PATH = os.path.join(os.path.dirname(__file__), "../app/src/main/res/xml/spellchecker.xml")
|
||||
|
||||
XML_CONFIG_HEADER = \
|
||||
"""<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Auto-generated by "utils/{file_name}" on {android_sdk_version} - DO NOT EDIT BY HAND!! -->
|
||||
<!-- Last update: {timestamp} -->
|
||||
<spell-checker xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:label="@string/floris_app_name"
|
||||
android:settingsActivity="dev.patrickgold.florisboard.SettingsLauncherAlias">
|
||||
"""
|
||||
|
||||
XML_CONFIG_SUBTYPE = \
|
||||
""" <subtype android:label="@string/general__system_string_placeholder" android:subtypeLocale="{lang_code}"/>
|
||||
"""
|
||||
|
||||
XML_CONFIG_FOOTER = \
|
||||
"""</spell-checker>
|
||||
"""
|
||||
|
||||
def get_sdk_version() -> str:
|
||||
version = subprocess.run(GET_ANDROID_VERSION_CMP, shell=True, capture_output=True).stdout.decode().strip()
|
||||
sdk = subprocess.run(GET_SDK_VERSION_CMP, shell=True, capture_output=True).stdout.decode().strip()
|
||||
return f"Android {version} (API {sdk})"
|
||||
|
||||
def get_language_list() -> list[str]:
|
||||
ret = subprocess.run(PULL_CMD, shell=True, capture_output=True, input=PULL_CMD_INPUT)
|
||||
ret_stderr = ret.stderr.decode()
|
||||
if (len(ret_stderr) > 0):
|
||||
raise Exception(ret_stderr)
|
||||
else:
|
||||
tsvFile = ret.stdout.decode()
|
||||
lang_code_list = list()
|
||||
for line in tsvFile.splitlines():
|
||||
lang_code = line.split('\t')[0]
|
||||
if (lang_code.find('-') < 0):
|
||||
lang_code_list.append(lang_code)
|
||||
return lang_code_list
|
||||
|
||||
def write_spellcheck_config(path: str, lang_code_list: list[str]):
|
||||
with open(path, 'wt') as config_file:
|
||||
config_file.write(XML_CONFIG_HEADER.format(
|
||||
file_name=os.path.basename(__file__),
|
||||
android_sdk_version=get_sdk_version(),
|
||||
timestamp=datetime.now().replace(microsecond=0).isoformat(),
|
||||
))
|
||||
for lang_code in lang_code_list:
|
||||
config_file.write(XML_CONFIG_SUBTYPE.format(lang_code=lang_code))
|
||||
config_file.write(XML_CONFIG_FOOTER)
|
||||
|
||||
def main():
|
||||
lang_code_list = get_language_list()
|
||||
write_spellcheck_config(XML_CONFIG_PATH, lang_code_list)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user