Language: the account's by default, Settings › Language, per-app locale
CI / check (push) Canceled after 0s

The app followed the phone's locale, so a Slovak phone showed Slovak while the
instance and the account were English. Now the default is the account's
language from /api/v2/me (read once per instance in use, kept in Prefs), and
Settings › Language offers Same as my account / Phone language / each language
the app has, named in itself.

Android 13+: LocaleManager.setApplicationLocales, and android:localeConfig
(res/xml/locales_config.xml, written by gen-strings.py from LANGS) so the
system's per-app language lists the same set; a choice made there is adopted
as the person's. Older phones: the chosen tag in a small synchronous file,
applied in attachBaseContext of every activity and to the assistant's window.
No AppCompat: the framework API covers it.

LanguageTest holds the offered list, the values-* folders and the locale
config equal. Screenshot 17-language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-10 08:06:47 +00:00
1 parent 6828dbd844
commit 37cf778c44
25 files changed
+467 -4

No files matched your search

+9
View File
@@ -5,6 +5,15 @@ is in alpha and releases come off `main`.
## [Unreleased]
### Changed
- **The app speaks your account's language**, the one chosen on your instance, rather than the
phone's: a phone set to Slovak signed in to an English account shows the app in English.
**Settings › Language** chooses otherwise -- *Same as my account* (the default), *Phone
language*, or any language the app has, each named in itself. On Android 13 and newer the
system's own per-app language (Settings › Apps › LLeMbas › Language) offers the same
languages, and a language chosen there is kept as your choice.
## [1.0.0-beta.4] — 2026-11-09
For LLeMbas server 2.0 (2.0.0-beta.7 or later for the Subagents setting and the panel's compaction).
+1
View File
@@ -20,6 +20,7 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/Theme.Lembas">
@@ -0,0 +1,109 @@
package eu.llembas.android
import android.app.Activity
import android.app.LocaleManager
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.os.LocaleList
import java.util.Locale
/**
* The app's language. By default the account's, from the server (`/api/v2/me`'s `language`), so
* a phone set to one language shows the app in the language the person chose on their instance;
* Settings › Language can choose the phone's language instead, or any language the app has.
*
* Android 13 and newer keep a per-app language themselves (`LocaleManager`, and the system's own
* Settings › Apps › LLeMbas › Language, which `res/xml/locales_config.xml` feeds). Older phones
* have none: there the chosen language is kept in a small synchronous file and every activity
* wraps its context in it ([wrap]), because the DataStore is read too late for `attachBaseContext`.
*/
object AppLanguage {
/** Prefs.language: the account's language (the default). */
const val ACCOUNT = ""
/** Prefs.language: the phone's language. */
const val PHONE = "system"
/**
* The languages the app has, by code, each named in itself. The same set as the
* `values-*` folders `scripts/gen-strings.py` writes, plus English; a test holds them equal.
*/
val LANGUAGES: List<Pair<String, String>> = listOf(
"en" to "English",
"cs" to "Čeština",
"de" to "Deutsch",
"es" to "Español",
"fr" to "Français",
"hu" to "Magyar",
"it" to "Italiano",
"pl" to "Polski",
"sk" to "Slovenčina",
)
private val CODES = LANGUAGES.map { it.first }.toSet()
/** A language's own name, or null for one the app does not have. */
fun name(code: String?): String? = LANGUAGES.firstOrNull { it.first == code?.lowercase()?.substringBefore('-')?.substringBefore('_') }?.second
/** The app's code for a server's language (`sk`, `pt_BR` -> `pt`), or null if the app lacks it. */
fun known(code: String?): String? = code?.trim()?.lowercase()?.substringBefore('-')?.substringBefore('_')?.takeIf { it in CODES }
/**
* The language the app should be in: a language tag, or null for the phone's own.
* [choice] is Prefs.language; [account] the account's language as the server last said it.
* An account in a language the app does not have follows the phone, rather than English.
*/
fun effective(choice: String, account: String): String? = when (choice) {
ACCOUNT -> known(account)
PHONE -> null
else -> known(choice)
}
private const val FILE = "language"
private const val APPLIED = "applied"
/** What [apply] last set; null if it never ran. */
fun applied(context: Context): String? = context.getSharedPreferences(FILE, Context.MODE_PRIVATE).getString(APPLIED, null)
/**
* What the system says the app's language is now (Android 13+): "" for the phone's. Differs
* from [applied] when the person chose a language in the system's settings for the app.
*/
fun systemChoice(context: Context): String? {
if (Build.VERSION.SDK_INT < 33) return null
val locales = context.getSystemService(LocaleManager::class.java)?.applicationLocales ?: return null
return if (locales.isEmpty) "" else locales[0].language
}
/**
* Put the app in [tag] (null: the phone's language). Does nothing when that is already so,
* so a running app is not recreated for nothing. Android 13+ recreates the activities
* itself; an older phone recreates [activity].
*/
fun apply(context: Context, tag: String?, activity: Activity? = null) {
val value = tag.orEmpty()
if (applied(context) == value && (Build.VERSION.SDK_INT < 33 || systemChoice(context) == value)) return
context.getSharedPreferences(FILE, Context.MODE_PRIVATE).edit().putString(APPLIED, value).commit()
if (Build.VERSION.SDK_INT >= 33) {
context.getSystemService(LocaleManager::class.java)?.applicationLocales =
if (value.isEmpty()) LocaleList.getEmptyLocaleList() else LocaleList.forLanguageTags(value)
} else {
activity?.recreate()
}
}
/**
* [base] in the chosen language, for `attachBaseContext` and for a window that is not an
* activity's (the assistant's sheet). Android 13+ does this itself; the context is returned
* as it is there.
*/
fun wrap(base: Context): Context {
if (Build.VERSION.SDK_INT >= 33) return base
val tag = base.getSharedPreferences(FILE, Context.MODE_PRIVATE).getString(APPLIED, null)
if (tag.isNullOrEmpty()) return base
val locale = Locale.forLanguageTag(tag)
val config = Configuration(base.resources.configuration).apply { setLocales(LocaleList(locale)) }
return base.createConfigurationContext(config)
}
}
@@ -1,6 +1,7 @@
package eu.llembas.android
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
@@ -49,6 +50,7 @@ import eu.llembas.android.ui.scheduled.SchedulingModelsScreen
import eu.llembas.android.ui.settings.SettingsScreen
import eu.llembas.android.ui.signin.SignInScreen
import eu.llembas.android.ui.theme.LembasTheme
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
@@ -62,10 +64,13 @@ class MainActivity : ComponentActivity() {
/** A chat or a schedule a notification, the assistant or a share asked to open; consumed once. */
private val opening = mutableStateOf<Opening?>(null)
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(AppLanguage.wrap(newBase))
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
take(intent)
followLanguage()
if (Build.VERSION.SDK_INT >= 33 &&
ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED
) {
@@ -79,6 +84,25 @@ class MainActivity : ComponentActivity() {
}
}
/**
* Keep the app in the language Settings › Language says: the account's by default. A
* language chosen for the app in the system's own settings (Android 13+) since the app last
* set one is the person's choice, and is kept as such.
*/
private fun followLanguage() {
lifecycleScope.launch {
val store = lembas.instances
val system = AppLanguage.systemChoice(this@MainActivity)
if (system != null && system != AppLanguage.applied(this@MainActivity).orEmpty()) {
store.savePrefs { it.copy(language = system.ifEmpty { AppLanguage.PHONE }) }
}
store.prefs
.map { AppLanguage.effective(it.language, it.accountLanguage) }
.distinctUntilChanged()
.collect { AppLanguage.apply(applicationContext, it, this@MainActivity) }
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
take(intent)
@@ -141,6 +165,13 @@ class MainActivity : ComponentActivity() {
scope.launch { drawer.close() }
nav.navigate(target)
}
// The account's language, which the app follows unless Settings › Language says
// otherwise. Read once per instance in use; kept, so the next start has it at once.
LaunchedEffect(instance.id) {
runCatching { lembas.instances.clientFor(instance).me() }.onSuccess { me ->
if (me.language.isNotBlank()) lembas.instances.savePrefs { it.copy(accountLanguage = me.language) }
}
}
// The list is read again each time the drawer opens, so a new title or a finished
// reply's dot is there without a pull.
LaunchedEffect(drawer.isOpen) { if (drawer.isOpen) chats.load() }
@@ -2,6 +2,7 @@ package eu.llembas.android.assist
import android.Manifest
import android.app.KeyguardManager
import android.content.Context
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
@@ -20,6 +21,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.lifecycle.lifecycleScope
import eu.llembas.android.AppLanguage
import eu.llembas.android.auth.Prefs
import eu.llembas.android.lembas
import eu.llembas.android.ui.theme.LembasTheme
@@ -36,6 +38,8 @@ class AssistActivity : ComponentActivity() {
if (granted) controller.listen()
}
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(AppLanguage.wrap(newBase))
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
@@ -20,6 +20,7 @@ import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import eu.llembas.android.AppLanguage
import eu.llembas.android.lembas
import eu.llembas.android.ui.theme.LembasTheme
import kotlinx.coroutines.CoroutineScope
@@ -66,7 +67,8 @@ class LembasAssistSession(context: Context) :
override fun onCreateContentView(): View {
val theme = runBlocking { context.lembas.instances.prefs.first() }.theme
return ComposeView(context).apply {
// In the app's language on a phone older than Android 13, which has no per-app one.
return ComposeView(AppLanguage.wrap(context)).apply {
setViewTreeLifecycleOwner(this@LembasAssistSession)
setViewTreeSavedStateRegistryOwner(this@LembasAssistSession)
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnDetachedFromWindow)
@@ -66,9 +66,19 @@ private val INSTANCES = stringPreferencesKey("instances")
private val ACTIVE = stringPreferencesKey("active")
private val PREFS = stringPreferencesKey("prefs")
/** What the person chose in Settings, for this phone. */
/**
* What the person chose in Settings, for this phone. [language]: "" the account's language (the
* default), "system" the phone's, or a language's code -- see [eu.llembas.android.AppLanguage].
* [accountLanguage] is the account's language as the instance in use last said it.
*/
@Serializable
data class Prefs(val theme: String = "", val assistantTemporary: Boolean = false, val readAloudSpoken: Boolean = true)
data class Prefs(
val theme: String = "",
val assistantTemporary: Boolean = false,
val readAloudSpoken: Boolean = true,
val language: String = "",
val accountLanguage: String = "",
)
class InstanceStore(private val context: Context) {
private val listSerializer = ListSerializer(Instance.serializer())
@@ -1,5 +1,6 @@
package eu.llembas.android.share
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -22,6 +23,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.content.IntentCompat
import androidx.lifecycle.lifecycleScope
import eu.llembas.android.AppLanguage
import eu.llembas.android.MainActivity
import eu.llembas.android.R
import eu.llembas.android.lembas
@@ -39,6 +41,8 @@ import kotlinx.coroutines.withContext
class ShareActivity : ComponentActivity() {
private val failure = mutableStateOf<String?>(null)
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(AppLanguage.wrap(newBase))
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
@@ -34,10 +34,12 @@ import androidx.compose.material.icons.filled.Palette
import androidx.compose.material.icons.filled.RecordVoiceOver
import androidx.compose.material.icons.filled.SystemUpdate
import androidx.compose.material.icons.filled.Timer
import androidx.compose.material.icons.filled.Translate
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
@@ -45,6 +47,7 @@ import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -62,6 +65,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.llembas.android.AppLanguage
import eu.llembas.android.BuildConfig
import eu.llembas.android.R
import eu.llembas.android.auth.Instance
@@ -78,6 +82,7 @@ interface SettingsActions {
fun add() {}
fun signOut(instance: Instance) {}
fun theme(value: String) {}
fun language(value: String) {}
fun enablePush(instance: Instance) {}
fun notificationSettings() {}
fun assistantSettings() {}
@@ -129,6 +134,11 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) {
scope.launch { store.savePrefs { it.copy(theme = value) } }
}
// MainActivity follows the choice: it puts the app in the language at once.
override fun language(value: String) {
scope.launch { store.savePrefs { it.copy(language = value) } }
}
override fun enablePush(instance: Instance) {
(context as? Activity)?.let { activity ->
Push.enable(activity, instance) { ok -> pushNote = context.getString(if (ok) R.string.push_on else R.string.push_failed) }
@@ -184,6 +194,15 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) {
@Composable
fun SettingsContent(state: SettingsState, actions: SettingsActions, onBack: () -> Unit = {}) {
val palette = LocalPalette.current
var choosingLanguage by remember { mutableStateOf(false) }
if (choosingLanguage) {
ModalBottomSheet(onDismissRequest = { choosingLanguage = false }, sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)) {
LanguageChoices(state.prefs, onPick = {
choosingLanguage = false
actions.language(it)
})
}
}
Scaffold(
containerColor = palette.bg,
topBar = {
@@ -248,6 +267,16 @@ fun SettingsContent(state: SettingsState, actions: SettingsActions, onBack: () -
}
}
}
item {
Group(stringResource(R.string.settings_language)) {
SettingRow(
Icons.Filled.Translate,
languageLabel(state.prefs),
subtitle = stringResource(R.string.language_hint),
onClick = { choosingLanguage = true },
)
}
}
item {
Group(stringResource(R.string.settings_theme)) {
listOf("" to R.string.theme_system, "moria" to R.string.theme_moria, "shire" to R.string.theme_shire).forEachIndexed { i, (value, label) ->
@@ -394,3 +423,70 @@ private fun Initial(name: String) {
Text(name.trim().firstOrNull()?.uppercase() ?: "?", style = MaterialTheme.typography.titleMedium, color = palette.accent)
}
}
/** The phone's own language, named in itself: what "Phone language" would show. */
private fun phoneLanguage(): String {
val locale = android.content.res.Resources.getSystem().configuration.locales[0]
return locale.getDisplayName(locale).replaceFirstChar { it.titlecase(locale) }
}
/** The language row's words: what is chosen, and for the account's, which language that is. */
@Composable
private fun languageLabel(prefs: Prefs): String = when (prefs.language) {
AppLanguage.ACCOUNT -> AppLanguage.name(prefs.accountLanguage)?.let { stringResource(R.string.language_account_is, it) }
?: stringResource(R.string.language_account)
AppLanguage.PHONE -> stringResource(R.string.language_phone_is, phoneLanguage())
else -> AppLanguage.name(prefs.language) ?: stringResource(R.string.language_account)
}
/**
* Settings › Language, as a sheet: the account's language (the default), the phone's, then every
* language the app has, each named in itself so a person who cannot read the current one still
* finds theirs.
*/
@Composable
fun LanguageChoices(prefs: Prefs, onPick: (String) -> Unit) {
val palette = LocalPalette.current
val choices = buildList {
add(
Triple(
AppLanguage.ACCOUNT,
stringResource(R.string.language_account),
AppLanguage.name(prefs.accountLanguage) ?: stringResource(R.string.language_account_unknown),
),
)
add(Triple(AppLanguage.PHONE, stringResource(R.string.language_phone), phoneLanguage()))
AppLanguage.LANGUAGES.forEach { (code, name) -> add(Triple(code, name, null)) }
}
LazyColumn(Modifier.fillMaxWidth(), contentPadding = PaddingValues(bottom = 24.dp)) {
item {
Text(
stringResource(R.string.settings_language),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(start = 24.dp, end = 24.dp, bottom = 8.dp),
)
}
choices.forEachIndexed { i, (value, title, subtitle) ->
item(key = "lang-$value-$i") {
if (i == 2) HorizontalDivider(color = palette.border, modifier = Modifier.padding(vertical = 4.dp))
Row(
Modifier
.fillMaxWidth()
.clickable { onPick(value) }
.heightIn(min = 56.dp)
.padding(horizontal = 24.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(title, style = MaterialTheme.typography.bodyLarge)
subtitle?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = palette.inkMuted) }
}
Spacer(Modifier.width(12.dp))
RadioButton(selected = prefs.language == value, onClick = { onPick(value) })
}
}
}
}
}
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Podle systému</string>
<string name="theme_moria">Moria (temná)</string>
<string name="theme_shire">Shire (světlý)</string>
<string name="settings_language">Jazyk</string>
<string name="language_hint">Jen rozhraní. Modely odpovídají v jazyce, ve kterém jim píšete, bez ohledu na toto nastavení.</string>
<string name="language_account">Stejný jako můj účet</string>
<string name="language_account_is">Stejný jako můj účet: %1$s</string>
<string name="language_account_unknown">Z vaší instance zatím nenačteno</string>
<string name="language_phone">Jazyk telefonu</string>
<string name="language_phone_is">Jazyk telefonu: %1$s</string>
<string name="settings_notifications">Upozornění</string>
<string name="push_explained">Upozornění chodí přes UnifiedPush, bez služeb Google: doručuje je distribuční aplikace, kterou jste zvolili; jsou zašifrované jen pro tento telefon.</string>
<string name="push_no_distributor">Abyste se dozvěděli, že je odpověď hotová, nainstalujte distributora UnifiedPush, například ntfy, a pak se vraťte sem. Bez něj aplikace nové odpovědi ukáže, jen když je otevřená.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Wie das System</string>
<string name="theme_moria">Moria (dunkel)</string>
<string name="theme_shire">Shire (hell)</string>
<string name="settings_language">Sprache</string>
<string name="language_hint">Nur die Oberfläche. Modelle antworten in der Sprache, in der Sie ihnen schreiben, egal was hier steht.</string>
<string name="language_account">Wie mein Konto</string>
<string name="language_account_is">Wie mein Konto: %1$s</string>
<string name="language_account_unknown">Noch nicht von Ihrer Instanz gelesen</string>
<string name="language_phone">Sprache des Telefons</string>
<string name="language_phone_is">Sprache des Telefons: %1$s</string>
<string name="settings_notifications">Benachrichtigungen</string>
<string name="push_explained">Benachrichtigungen kommen über UnifiedPush, ohne Google-Dienste: Die von Ihnen gewählte Distributor-App trägt sie, verschlüsselt nur für dieses Telefon.</string>
<string name="push_no_distributor">Um erfahren zu lassen, wenn eine Antwort fertig ist, installieren Sie einen UnifiedPush-Distributor wie ntfy und kommen Sie dann hierher zurück. Ohne einen zeigt die App neue Antworten nur, wenn sie geöffnet ist.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Como el sistema</string>
<string name="theme_moria">Moria (oscuro)</string>
<string name="theme_shire">Shire (claro)</string>
<string name="settings_language">Idioma</string>
<string name="language_hint">Solo la interfaz. Los modelos responden en el idioma en el que usted les escribe, diga lo que diga esto.</string>
<string name="language_account">Igual que mi cuenta</string>
<string name="language_account_is">Igual que mi cuenta: %1$s</string>
<string name="language_account_unknown">Aún no se ha leído de su instancia</string>
<string name="language_phone">Idioma del teléfono</string>
<string name="language_phone_is">Idioma del teléfono: %1$s</string>
<string name="settings_notifications">Notificaciones</string>
<string name="push_explained">Las notificaciones llegan mediante UnifiedPush, sin servicios de Google: la aplicación distribuidora que eligió las transporta, cifradas solo para este teléfono.</string>
<string name="push_no_distributor">Para que le avisen cuando una respuesta esté lista, instale un distribuidor de UnifiedPush como ntfy y luego vuelva aquí. Sin uno, la aplicación muestra las respuestas nuevas solo cuando está abierta.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Comme le système</string>
<string name="theme_moria">Moria (sombre)</string>
<string name="theme_shire">Shire (clair)</string>
<string name="settings_language">Langue</string>
<string name="language_hint">L\'interface uniquement. Les modèles répondent dans la langue dans laquelle vous leur écrivez, quoi qu\'indique ce réglage.</string>
<string name="language_account">Comme mon compte</string>
<string name="language_account_is">Comme mon compte : %1$s</string>
<string name="language_account_unknown">Pas encore lue sur votre instance</string>
<string name="language_phone">Langue du téléphone</string>
<string name="language_phone_is">Langue du téléphone : %1$s</string>
<string name="settings_notifications">Notifications</string>
<string name="push_explained">Les notifications arrivent par UnifiedPush, sans services Google : l\'application distributrice que vous avez choisie les transporte, chiffrées pour ce téléphone uniquement.</string>
<string name="push_no_distributor">Pour être averti quand une réponse est prête, installez un distributeur UnifiedPush tel que ntfy, puis revenez ici. Sans cela, l\'application affiche les nouvelles réponses seulement quand elle est ouverte.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">A rendszer szerint</string>
<string name="theme_moria">Moria (sötét)</string>
<string name="theme_shire">Shire (világos)</string>
<string name="settings_language">Nyelv</string>
<string name="language_hint">Csak a felület. A modellek azon a nyelven válaszolnak, amelyen ír nekik, függetlenül ettől a beállítástól.</string>
<string name="language_account">Ugyanaz, mint a fiókomé</string>
<string name="language_account_is">Ugyanaz, mint a fiókomé: %1$s</string>
<string name="language_account_unknown">Még nincs beolvasva a példányáról</string>
<string name="language_phone">A telefon nyelve</string>
<string name="language_phone_is">A telefon nyelve: %1$s</string>
<string name="settings_notifications">Értesítések</string>
<string name="push_explained">Az értesítések a UnifiedPush-on keresztül érkeznek, Google-szolgáltatások nélkül: az Ön által választott elosztó alkalmazás szállítja őket, titkosítva, csak ehhez a telefonhoz.</string>
<string name="push_no_distributor">Hogy értesítést kapjon, amikor egy válasz elkészül, telepítsen egy UnifiedPush-elosztót, például az ntfy-t, majd jöjjön vissza ide. Ha nincs ilyen, az alkalmazás csak akkor mutatja az új válaszokat, amikor meg van nyitva.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Come il sistema</string>
<string name="theme_moria">Moria (scuro)</string>
<string name="theme_shire">Shire (chiaro)</string>
<string name="settings_language">Lingua</string>
<string name="language_hint">Solo l\'interfaccia. I modelli rispondono nella lingua in cui scrivi loro, qualunque cosa dica questa impostazione.</string>
<string name="language_account">Come il mio account</string>
<string name="language_account_is">Come il mio account: %1$s</string>
<string name="language_account_unknown">Non ancora letta dalla sua istanza</string>
<string name="language_phone">Lingua del telefono</string>
<string name="language_phone_is">Lingua del telefono: %1$s</string>
<string name="settings_notifications">Notifiche</string>
<string name="push_explained">Le notifiche arrivano tramite UnifiedPush, senza servizi Google: l\'app di distribuzione che hai scelto le trasporta, cifrate solo per questo telefono.</string>
<string name="push_no_distributor">Per essere avvisato quando una risposta è pronta, installa un distributore UnifiedPush come ntfy, poi torna qui. Senza uno, l\'app mostra le nuove risposte solo quando è aperta.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Jak system</string>
<string name="theme_moria">Moria (ciemny)</string>
<string name="theme_shire">Shire (jasny)</string>
<string name="settings_language">Język</string>
<string name="language_hint">Tylko interfejs. Modele odpowiadają w języku, w którym się do nich pisze, bez względu na to ustawienie.</string>
<string name="language_account">Tak jak moje konto</string>
<string name="language_account_is">Tak jak moje konto: %1$s</string>
<string name="language_account_unknown">Jeszcze nie odczytano z Twojej instancji</string>
<string name="language_phone">Język telefonu</string>
<string name="language_phone_is">Język telefonu: %1$s</string>
<string name="settings_notifications">Powiadomienia</string>
<string name="push_explained">Powiadomienia przychodzą przez UnifiedPush, bez usług Google: niesie je wybrana aplikacja dystrybucyjna, zaszyfrowane tylko dla tego telefonu.</string>
<string name="push_no_distributor">Aby dostawać informacje, kiedy odpowiedź jest gotowa, zainstaluj dystrybutora UnifiedPush, na przykład ntfy, a potem wróć tutaj. Bez niego aplikacja pokazuje nowe odpowiedzi tylko wtedy, gdy jest otwarta.</string>
+7
View File
@@ -235,6 +235,13 @@
<string name="theme_system">Podľa systému</string>
<string name="theme_moria">Moria (tmavá)</string>
<string name="theme_shire">Shire (svetlá)</string>
<string name="settings_language">Jazyk</string>
<string name="language_hint">Len rozhranie. Modely odpovedajú v jazyku, v ktorom im píšete, bez ohľadu na toto nastavenie.</string>
<string name="language_account">Rovnaký ako môj účet</string>
<string name="language_account_is">Rovnaký ako môj účet: %1$s</string>
<string name="language_account_unknown">Z vašej inštancie ešte nenačítaný</string>
<string name="language_phone">Jazyk telefónu</string>
<string name="language_phone_is">Jazyk telefónu: %1$s</string>
<string name="settings_notifications">Upozornenia</string>
<string name="push_explained">Upozornenia chodia cez UnifiedPush, bez služieb Google: doručuje ich distribučná aplikácia, ktorú ste zvolili, zašifrované len pre tento telefón.</string>
<string name="push_no_distributor">Aby ste sa dozvedeli, že je odpoveď hotová, nainštalujte distributora UnifiedPush, napríklad ntfy, a potom sa vráťte sem. Bez neho aplikácia nové odpovede ukáže, len keď je otvorená.</string>
+7
View File
@@ -236,6 +236,13 @@
<string name="theme_system">As the system</string>
<string name="theme_moria">Moria (dark)</string>
<string name="theme_shire">Shire (light)</string>
<string name="settings_language">Language</string>
<string name="language_hint">The interface only. Models answer in the language you write to them in, whatever this says.</string>
<string name="language_account">Same as my account</string>
<string name="language_account_is">Same as my account: %1$s</string>
<string name="language_account_unknown">Not read from your instance yet</string>
<string name="language_phone">Phone language</string>
<string name="language_phone_is">Phone language: %1$s</string>
<string name="settings_notifications">Notifications</string>
<string name="push_explained">Notifications come through UnifiedPush, with no Google services: the distributor app you chose carries them, encrypted for this phone only.</string>
<string name="push_no_distributor">To be told when a reply is ready, install a UnifiedPush distributor such as ntfy, then come back here. Without one, the app shows new replies when it is open.</string>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by scripts/gen-strings.py. Edit LANGS there. -->
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en" />
<locale android:name="cs" />
<locale android:name="de" />
<locale android:name="es" />
<locale android:name="fr" />
<locale android:name="hu" />
<locale android:name="it" />
<locale android:name="pl" />
<locale android:name="sk" />
</locale-config>
@@ -0,0 +1,53 @@
package eu.llembas.android
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import java.io.File
class LanguageTest {
@Test
fun theAccountsLanguageIsTheDefault() {
assertEquals("en", AppLanguage.effective(AppLanguage.ACCOUNT, "en"))
assertEquals("sk", AppLanguage.effective(AppLanguage.ACCOUNT, "sk"))
// A server language written with a region still names one the app has.
assertEquals("cs", AppLanguage.effective(AppLanguage.ACCOUNT, "cs_CZ"))
}
@Test
fun anUnknownOrUnreadAccountLanguageFollowsThePhone() {
assertNull(AppLanguage.effective(AppLanguage.ACCOUNT, ""))
assertNull(AppLanguage.effective(AppLanguage.ACCOUNT, "ja"))
}
@Test
fun aChoiceBeatsTheAccount() {
assertNull(AppLanguage.effective(AppLanguage.PHONE, "en"))
assertEquals("de", AppLanguage.effective("de", "en"))
// A code the app no longer has (a newer build's choice, say) follows the phone.
assertNull(AppLanguage.effective("ja", "en"))
}
@Test
fun everyLanguageIsNamedInItself() {
assertEquals("Slovenčina", AppLanguage.name("sk"))
assertEquals("English", AppLanguage.name("en-GB"))
assertNull(AppLanguage.name("ja"))
}
/** The list Settings offers, the strings gen-strings.py writes, and the locale config agree. */
@Test
fun theLanguagesAreTheOnesTheAppHasStringsFor() {
val res = File("src/main/res")
val folders = res.listFiles().orEmpty()
.map { it.name }
.filter { it.startsWith("values-") && File(res, "$it/strings.xml").exists() }
.map { it.removePrefix("values-") }
.toSet()
val offered = AppLanguage.LANGUAGES.map { it.first }.toSet()
assertEquals(offered - "en", folders)
val config = File(res, "xml/locales_config.xml").readText()
val listed = Regex("""android:name="([a-z]+)"""").findAll(config).map { it.groupValues[1] }.toSet()
assertEquals(offered, listed)
}
}
@@ -213,7 +213,7 @@ object Fakes {
val settings = SettingsState(
instances = listOf(home, work),
active = home,
prefs = Prefs(theme = "", assistantTemporary = true),
prefs = Prefs(theme = "", assistantTemporary = true, accountLanguage = "en"),
hasDistributor = true,
version = "1.0.0-beta.3",
selfUpdate = true,
@@ -30,6 +30,7 @@ import eu.llembas.android.ui.scheduled.ScheduleContent
import eu.llembas.android.ui.scheduled.ScheduleEditContent
import eu.llembas.android.ui.scheduled.ScheduledContent
import eu.llembas.android.ui.scheduled.SchedulingModelsContent
import eu.llembas.android.ui.settings.LanguageChoices
import eu.llembas.android.ui.settings.SettingsActions
import eu.llembas.android.ui.settings.SettingsContent
import eu.llembas.android.ui.theme.LocalPalette
@@ -119,6 +120,12 @@ class ScreenShots {
shoot("08-settings", Phone.Small) { SettingsContent(Fakes.settings, NoSettingsActions) }
}
@Test
fun language() {
shoot("17-language", Phone.Scroll) { SheetOver { LanguageChoices(Fakes.settings.prefs, onPick = {}) } }
shoot("17-language", Phone.Small, fontScale = 1.5f) { SheetOver { LanguageChoices(Fakes.settings.prefs, onPick = {}) } }
}
@Test
fun scheduled() {
shoot("09-scheduled") { ScheduledContent(Fakes.scheduled) }
+13
View File
@@ -103,6 +103,18 @@ def write(folder: Path, entries: dict[str, str]) -> None:
(folder / "strings.xml").write_text("\n".join(lines) + "\n", encoding="utf-8")
def write_locale_config() -> None:
"""`res/xml/locales_config.xml`: the languages the app has, for Android 13+'s per-app language
(the manifest's `android:localeConfig`). Written from LANGS, so it cannot list a language
the app has no strings for, or miss one it has."""
lines = ['<?xml version="1.0" encoding="utf-8"?>', HEADER.replace("Edit scripts/strings.py or strings_own.json", "Edit LANGS there"),
'<locale-config xmlns:android="http://schemas.android.com/apk/res/android">',
' <locale android:name="en" />']
lines += [f' <locale android:name="{code}" />' for code in LANGS]
lines.append("</locale-config>")
(RES / "xml/locales_config.xml").write_text("\n".join(lines) + "\n", encoding="utf-8")
def main() -> None:
used = used_keys()
missing = sorted(used - set(STRINGS))
@@ -123,6 +135,7 @@ def main() -> None:
).stdout.strip()
own = json.loads((Path(__file__).parent / "strings_own.json").read_text(encoding="utf-8"))
write(RES / "values", STRINGS)
write_locale_config()
for code in LANGS:
catalogue = server_catalogue(code, ref)
mine = own.get(code, {})
+8
View File
@@ -255,6 +255,14 @@ STRINGS: dict[str, str] = {
"theme_system": "As the system",
"theme_moria": "Moria (dark)",
"theme_shire": "Shire (light)",
# Language
"settings_language": "Language",
"language_hint": "The interface only. Models answer in the language you write to them in, whatever this says.",
"language_account": "Same as my account",
"language_account_is": "Same as my account: %1$s",
"language_account_unknown": "Not read from your instance yet",
"language_phone": "Phone language",
"language_phone_is": "Phone language: %1$s",
"settings_notifications": "Notifications",
"push_explained": "Notifications come through UnifiedPush, with no Google services: the distributor app you chose carries them, encrypted for this phone only.",
"push_no_distributor": "To be told when a reply is ready, install a UnifiedPush distributor such as ntfy, then come back here. Without one, the app shows new replies when it is open.",
+40
View File
@@ -48,6 +48,11 @@
"empty_chat": "O čem si promluvíme?",
"empty_chats": "Zatím žádné konverzace. Ne všichni, kdo bloudí, jsou ztraceni — založte jednu.",
"instance_in_use": "Používá se",
"language_account": "Stejný jako můj účet",
"language_account_is": "Stejný jako můj účet: %1$s",
"language_account_unknown": "Z vaší instance zatím nenačteno",
"language_phone": "Jazyk telefonu",
"language_phone_is": "Jazyk telefonu: %1$s",
"listening": "Naslouchám…",
"loading_line": "Pečou se lembasy…",
"mode_continue": "Jeden chat, který roste",
@@ -215,6 +220,11 @@
"empty_chat": "Worüber sprechen wir?",
"empty_chats": "Noch keine Chats. Nicht jeder, der wandert, ist verloren — fangen Sie einen an.",
"instance_in_use": "In Verwendung",
"language_account": "Wie mein Konto",
"language_account_is": "Wie mein Konto: %1$s",
"language_account_unknown": "Noch nicht von Ihrer Instanz gelesen",
"language_phone": "Sprache des Telefons",
"language_phone_is": "Sprache des Telefons: %1$s",
"listening": "Hört zu…",
"loading_line": "Lembas wird gebacken…",
"mode_continue": "Ein Chat, der wächst",
@@ -383,6 +393,11 @@
"empty_chat": "¿De qué hablamos?",
"empty_chats": "Aún no hay chats. No todos los que vagan están perdidos — empiece uno.",
"instance_in_use": "En uso",
"language_account": "Igual que mi cuenta",
"language_account_is": "Igual que mi cuenta: %1$s",
"language_account_unknown": "Aún no se ha leído de su instancia",
"language_phone": "Idioma del teléfono",
"language_phone_is": "Idioma del teléfono: %1$s",
"listening": "Escuchando…",
"loading_line": "Horneando lembas…",
"mode_continue": "Un chat que crece",
@@ -550,6 +565,11 @@
"empty_chat": "De quoi allons-nous parler ?",
"empty_chats": "Pas encore de conversation. Tous ceux qui errent ne sont pas perdus — commencez-en une.",
"instance_in_use": "Utilisée",
"language_account": "Comme mon compte",
"language_account_is": "Comme mon compte : %1$s",
"language_account_unknown": "Pas encore lue sur votre instance",
"language_phone": "Langue du téléphone",
"language_phone_is": "Langue du téléphone : %1$s",
"listening": "Écoute…",
"loading_line": "Cuisson des lembas…",
"mode_continue": "Une discussion qui s’allonge",
@@ -718,6 +738,11 @@
"empty_chat": "Miről beszéljünk?",
"empty_chats": "Még nincs csevegés. Nem mindenki van elveszve, aki bolyong — kezdjen el egyet.",
"instance_in_use": "Használatban",
"language_account": "Ugyanaz, mint a fiókomé",
"language_account_is": "Ugyanaz, mint a fiókomé: %1$s",
"language_account_unknown": "Még nincs beolvasva a példányáról",
"language_phone": "A telefon nyelve",
"language_phone_is": "A telefon nyelve: %1$s",
"listening": "Hallgatja…",
"loading_line": "Lembas sül…",
"mode_continue": "Egy csevegés, amely bővül",
@@ -886,6 +911,11 @@
"empty_chat": "Di cosa parliamo?",
"empty_chats": "Ancora nessuna chat. Non tutti quelli che vagano sono perduti — iniziane una.",
"instance_in_use": "In uso",
"language_account": "Come il mio account",
"language_account_is": "Come il mio account: %1$s",
"language_account_unknown": "Non ancora letta dalla sua istanza",
"language_phone": "Lingua del telefono",
"language_phone_is": "Lingua del telefono: %1$s",
"listening": "In ascolto…",
"loading_line": "I lembas stanno cuocendo…",
"mode_continue": "Una chat che cresce",
@@ -1053,6 +1083,11 @@
"empty_chat": "O czym porozmawiamy?",
"empty_chats": "Nie ma jeszcze czatów. Nie każdy, kto błądzi, jest zgubiony — zacznij jeden.",
"instance_in_use": "W użyciu",
"language_account": "Tak jak moje konto",
"language_account_is": "Tak jak moje konto: %1$s",
"language_account_unknown": "Jeszcze nie odczytano z Twojej instancji",
"language_phone": "Język telefonu",
"language_phone_is": "Język telefonu: %1$s",
"listening": "Słucham…",
"loading_line": "Lembasy się pieczą…",
"mode_continue": "Jeden czat, który rośnie",
@@ -1220,6 +1255,11 @@
"empty_chat": "O čom sa pozhovárame?",
"empty_chats": "Zatiaľ žiadne konverzácie. Nie všetci, čo blúdia, sú stratení — začnite jednu.",
"instance_in_use": "Používa sa",
"language_account": "Rovnaký ako môj účet",
"language_account_is": "Rovnaký ako môj účet: %1$s",
"language_account_unknown": "Z vašej inštancie ešte nenačítaný",
"language_phone": "Jazyk telefónu",
"language_phone_is": "Jazyk telefónu: %1$s",
"listening": "Počúvam…",
"loading_line": "Pečú sa lembasy…",
"mode_continue": "Jedna konverzácia, ktorá rastie",