Colota - Android GPS Location tracker
feat(i18n): add a language picker and a contributor guide for translations (#918)
Max Dietrichb5fb206fac7e
diff --git a/.github/labeler.yml b/.github/labeler.ymlindex 2c892ad7..e85c4b4a 100644--- a/.github/labeler.yml+++ b/.github/labeler.yml@@ -55,6 +55,7 @@ i18n:- any-glob-to-any-file:- 'apps/mobile/src/i18n/**'- 'apps/mobile/android/app/src/main/res/values*/strings.xml'+ - 'apps/mobile/android/app/src/main/res/xml/locales_config.xml'# ============================# Shared package (types, theme)diff --git a/apps/docs/docs/configuration/appearance.md b/apps/docs/docs/configuration/appearance.mdindex c3a1fccd..20bf332b 100644--- a/apps/docs/docs/configuration/appearance.md+++ b/apps/docs/docs/configuration/appearance.md@@ -10,15 +10,16 @@ import ScreenshotGallery from '@site/src/components/ScreenshotGallery'<ScreenshotGallery screenshots={[ { src: "/img/screenshots/AppearanceSettings.png", label: "Appearance" }, ]} />-| Setting | Options | Default |-| ---------------- | ------------------------- | ------------------------ |-| Theme | System / Light / Dark | System |-| Wallpaper colors | On/Off | Off |-| Units | Metric / Imperial | From the device language |-| Time format | 24h / 12h | From the device language |-| Map tile server | Light and dark style URLs | maps.mxd.codes |+| Setting | Options | Default |+| ---------------- | --------------------------------- | ------------------------ |+| Theme | System / Light / Dark | System |+| Wallpaper colors | On/Off | Off |+| Units | Metric / Imperial | From the device language |+| Time format | 24h / 12h | From the device language |+| Language | System default / each translation | System default |+| Map tile server | Light and dark style URLs | maps.mxd.codes |-Appearance settings are included in a [backup](/docs/guides/backup-restore).+Appearance settings are included in a [backup](/docs/guides/backup-restore), except Language, which Android stores with the app.## Theme@@ -44,6 +45,16 @@ The distance fields in tracking settings follow this choice. See [Tracking SettiThe row's hint shows the current time in the chosen format. Until you pick one, Colota follows the clock format of the device language.+## Language++Tap **Language** to pick the app's language. **System default** follows the phone's language and falls back to English when Colota has no translation for it. Each language is listed in its own words. Screens switch at once; the tracking notification follows on its next update.++On Android 13 and later the same choice is under **Android Settings → Apps → Colota → Language**.++Messages from the tracking service, such as a failed Test connection, stay in English.++To add a language, see [Translations](/docs/development/translations).+## Map Tile ServerTap **Map tile server** to enter a style URL for light theme and one for dark theme. Leave a field empty to use the default server. A URL that does not start with `http://` or `https://` and name a host is refused. **Reset to default** clears both fields.diff --git a/apps/docs/docs/contributing.md b/apps/docs/docs/contributing.mdindex 4f55bda6..f84927a2 100644--- a/apps/docs/docs/contributing.md+++ b/apps/docs/docs/contributing.md@@ -19,4 +19,6 @@ sidebar_position: 84. Test on a real device5. Open a Pull Request+To translate Colota, see [Translations](/docs/development/translations).+[Architecture](/docs/development/architecture) covers the native modules and the tracking flow.diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.mdindex 37ed7365..663ebfea 100644--- a/apps/docs/docs/development/architecture.md+++ b/apps/docs/docs/development/architecture.md@@ -287,7 +287,7 @@ For backups, two `internal` methods support the export/import flow without expos| `PayloadBuilder` | Builds outgoing JSON payloads (field-mapped, Overland batch envelope, Traccar JSON) and extracts envelope custom fields || `ServiceConfig` | Centralized configuration data class || `TimedCache` | Generic TTL cache used for queue count, device info, profiles, and network state |-| `BuildConfigModule` | Exposes the version name, version code, flavor and device language to JS, plus `getSystemPalette` - the Android 12+ wallpaper tonal steps as `#RRGGBB` hex, null below API 31 |+| `BuildConfigModule` | Exposes the version name, version code, flavor and device language to JS, plus `getSystemPalette` - the Android 12+ wallpaper tonal steps as `#RRGGBB` hex, null below API 31 - and the in-app language through AppCompat's per-app locale API: `getAppLanguage` (the pick and the language in use) and `setAppLanguage`. `MainActivity` handles `locale` and `layoutDirection` itself, so a switch does not recreate it, and native text is read through `util/AppLanguage`, because below Android 13 AppCompat localises activities only || `AppLogger` | Centralized logger - always active, all tags prefixed with `Colota.` for logcat filtering || `AutoExportWorker` | WorkManager `CoroutineWorker` enqueued by `AutoExportAlarmReceiver` - performs the export (chunked writes to a per-run temp file, foreground service, retries, retention cleanup), verifies the copy by bytes written and re-arms the next alarm in `finally` || `AutoExportAlarmReceiver` | Broadcast receiver fired by AlarmManager at the configured time - hands off to `AutoExportWorker` because the receiver's 10s budget can't run an export |diff --git a/apps/docs/docs/development/translations.md b/apps/docs/docs/development/translations.mdnew file mode 100644index 00000000..a94e2985--- /dev/null+++ b/apps/docs/docs/development/translations.md@@ -0,0 +1,40 @@+---+sidebar_position: 4+---++# Translations++A translation can be partial: a line you leave out shows in English.++Colota's text lives in two files:++| File | Holds |+| --------------------------------------------------------- | ----------------------------------------------- |+| `apps/mobile/src/i18n/locales/en.json` | The app's screens, dialogs and labels |+| `apps/mobile/android/app/src/main/res/values/strings.xml` | Notifications, notification channels and toasts |++Error messages from the tracking service and every log line stay in English, so logs from any user read the same.++## Add a Language++1. Fork and clone [the repository](https://github.com/dietrichmax/colota).+2. Copy `en.json` to `<code>.json` in the same folder, where `<code>` is the two-letter language code, and translate the values. Keys stay as they are.+3. Copy `res/values/strings.xml` to `res/values-<code>/strings.xml` and translate it.+4. Optional: run `npx -w @colota/mobile jest src/i18n` after `npm ci` and `npm run build -w @colota/shared`. It checks that your file uses English keys only and keeps every placeholder; the pull request runs the same check.+5. Optional: to try the translation in the app, register the language:+ - In `apps/mobile/src/i18n/options.ts`, import your file, add the code to `SUPPORTED_LANGUAGES`, the language's own name to `LANGUAGE_NAMES` (`de: "Deutsch"`) and the file to `resources`.+ - In `apps/mobile/android/app/src/main/res/xml/locales_config.xml`, add `<locale android:name="<code>" />`. A test fails when this list and `SUPPORTED_LANGUAGES` disagree.+ - Build and install the app as in [Local Setup](./local-setup), then pick the language under **Settings → Appearance → Language**. A release build does not notice a changed `.json` file on its own: delete `apps/mobile/android/app/build/generated/assets/react` first.+6. Open a pull request. If you skipped step 5, the maintainer registers the language.++Regional variants such as `pt-BR`, right-to-left languages such as Arabic and languages with more than two plural forms such as Polish or Russian need changes in the app first. Open an issue before you start.++## Rules++- **Escaping in `strings.xml`**: write an apostrophe as `\'` and an ampersand as `&`. Keep a percent sign and the tag attributes as the English has them.+- **Placeholders**: keep `{{name}}` in `en.json` and `%s`, `%d`, `%1$d` in `strings.xml` exactly as they are. Move them where your grammar needs them.+- **Plurals**: in `en.json` a key ending in `_one` is the singular and `_other` the plural. In `strings.xml` translate every `<item>` inside a `<plurals>` block.+- **Fragments**: a text that starts lowercase in English is part of a longer sentence. Translate it to fit mid-sentence.+- **Keep as is**: product and format names (Colota, GeoJSON, GPX, OwnTracks, Traccar), unit symbols and technical terms such as HTTPS or SSID.+- **Everyday words**: write what people say in your language, not a word-for-word translation. Where an English term is common in everyday use, such as Tracking or Upload in German, keep it.+- **Tone**: short and plain, like the English.diff --git a/apps/docs/sidebars.ts b/apps/docs/sidebars.tsindex 3ae861ec..5dc82aae 100644--- a/apps/docs/sidebars.ts+++ b/apps/docs/sidebars.ts@@ -64,7 +64,12 @@ const sidebars: SidebarsConfig = {{type: "category",label: "Development",- items: ["development/architecture", "development/local-setup", "development/permissions"]+ items: [+ "development/architecture",+ "development/local-setup",+ "development/permissions",+ "development/translations"+ ]},{type: "doc",diff --git a/apps/mobile/App.tsx b/apps/mobile/App.tsxindex 39b489ff..c9ba42f8 100644--- a/apps/mobile/App.tsx+++ b/apps/mobile/App.tsx@@ -2,12 +2,12 @@* Copyright (C) 2026 Max Dietrich* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.*/-import React, { useMemo, useState, useCallback } from "react"+import React, { useMemo, useState, useCallback, useEffect } from "react"import { NavigationContainer, NavigationContainerRef, DefaultTheme, DarkTheme } from "@react-navigation/native"import { LucideProvider } from "lucide-react-native"import { createNativeStackNavigator } from "@react-navigation/native-stack"import { SafeAreaProvider } from "react-native-safe-area-context"-import { View, StatusBar, Platform, StyleSheet } from "react-native"+import { View, StatusBar, Platform, StyleSheet, AppState } from "react-native"import { ThemeProvider, useTheme } from "./src/hooks/useTheme"import { fonts } from "./src/styles/typography"import { TrackingProvider } from "./src/contexts/TrackingProvider"@@ -16,6 +16,7 @@ import type { RootStackParamList, RootStackRoute } from "./src/types/navigation"import "./src/i18n"import { useTranslation } from "./src/i18n/useTranslation"+import { syncLanguage } from "./src/i18n/language"import type { TranslationKey } from "./src/i18n/options"import {LoggingScreen,@@ -42,6 +43,7 @@ import {TripDetailScreen,OfflineMapsScreen,AppearanceScreen,+ LanguageScreen,ConnectionScreen,TrackingSyncScreen,BackupRestoreScreen@@ -185,6 +187,11 @@ const SCREEN_CONFIG: readonly ScreenConfig[] = [component: AppearanceScreen,titleKey: "screen.appearance"},+ {+ name: "Language",+ component: LanguageScreen,+ titleKey: "screen.language"+ },{name: "Connection",component: ConnectionScreen,@@ -201,6 +208,14 @@ function AppNavigator() {const { colors, isDark } = useTheme()const { t } = useTranslation()const [currentRoute, setCurrentRoute] = useState<string | undefined>("Dashboard")++ // Android's own App languages page and a phone-language change never pass through the picker.+ useEffect(() => {+ const sub = AppState.addEventListener("change", (state) => {+ if (state === "active") syncLanguage()+ })+ return () => sub.remove()+ }, [])const screenOptions = useMemo(() => ({headerStyle: {diff --git a/apps/mobile/android/app/src/main/AndroidManifest.xml b/apps/mobile/android/app/src/main/AndroidManifest.xmlindex eae92466..fc10f5af 100644--- a/apps/mobile/android/app/src/main/AndroidManifest.xml+++ b/apps/mobile/android/app/src/main/AndroidManifest.xml@@ -46,12 +46,23 @@android:allowBackup="false"android:theme="@style/AppTheme"android:supportsRtl="true"- android:networkSecurityConfig="@xml/network_security_config">+ android:networkSecurityConfig="@xml/network_security_config"+ android:localeConfig="@xml/locales_config">++ <!-- Stores the in-app language choice below Android 13, which has no per-app language of its own. -->+ <service+ android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"+ android:enabled="false"+ android:exported="false">+ <meta-data+ android:name="autoStoreLocales"+ android:value="true" />+ </service><activityandroid:name=".MainActivity"android:label="@string/app_name"- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"+ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|locale|layoutDirection"android:launchMode="singleTask"android:windowSoftInputMode="adjustPan"android:exported="true">diff --git a/apps/mobile/android/app/src/main/java/com/colota/backup/BackupForegroundService.kt b/apps/mobile/android/app/src/main/java/com/colota/backup/BackupForegroundService.ktindex dfcc2a70..26b54fbb 100644--- a/apps/mobile/android/app/src/main/java/com/colota/backup/BackupForegroundService.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/backup/BackupForegroundService.kt@@ -15,6 +15,7 @@ import android.os.Buildimport android.os.IBinderimport androidx.core.app.NotificationCompatimport androidx.core.content.ContextCompat+import com.Colota.util.AppLanguageimport com.Colota.Rimport com.Colota.util.AppLogger@@ -53,6 +54,8 @@ class BackupForegroundService : Service() {}}+ private val strings: Context get() = AppLanguage.context(this)+override fun onBind(intent: Intent?): IBinder? = nulloverride fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {@@ -63,10 +66,10 @@ class BackupForegroundService : Service() {}ensureChannel()- val message = intent.getStringExtra(EXTRA_MESSAGE) ?: getString(R.string.backup_working)+ val message = intent.getStringExtra(EXTRA_MESSAGE) ?: strings.getString(R.string.backup_working)val notification = NotificationCompat.Builder(this, CHANNEL_ID).setSmallIcon(android.R.drawable.ic_menu_save)- .setContentTitle(getString(R.string.backup_title))+ .setContentTitle(strings.getString(R.string.backup_title)).setContentText(message).setOngoing(true).setPriority(NotificationCompat.PRIORITY_LOW)@@ -100,9 +103,9 @@ class BackupForegroundService : Service() {val nm = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManagerval channel = NotificationChannel(CHANNEL_ID,- getString(R.string.channel_backup),+ strings.getString(R.string.channel_backup),NotificationManager.IMPORTANCE_LOW,- ).apply { description = getString(R.string.channel_backup_description) }+ ).apply { description = strings.getString(R.string.channel_backup_description) }nm.createNotificationChannel(channel)}}diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/BackupServiceModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/BackupServiceModule.ktindex 9c5a5949..26606e7f 100644--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/BackupServiceModule.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/BackupServiceModule.kt@@ -9,6 +9,7 @@ import android.content.Intentimport android.net.Uriimport android.os.StatFsimport android.provider.DocumentsContract+import com.Colota.util.AppLanguageimport com.Colota.Rimport com.Colota.backup.BackupBuilderimport com.Colota.backup.BackupError@@ -159,7 +160,7 @@ class BackupServiceModule(reactContext: ReactApplicationContext) :try {ensureFreeSpaceForBackup()- startForegroundOnMain(reactApplicationContext.getString(R.string.backup_encrypting))+ startForegroundOnMain(AppLanguage.context(reactApplicationContext).getString(R.string.backup_encrypting))pendingFile.outputStream().use { out ->BackupBuilder(reactApplicationContext).build(out, passwordChars)@@ -253,7 +254,7 @@ class BackupServiceModule(reactContext: ReactApplicationContext) :val uri = Uri.parse(uriString)ensureFreeSpaceForRestore(uri)- startForegroundOnMain(reactApplicationContext.getString(R.string.backup_restoring))+ startForegroundOnMain(AppLanguage.context(reactApplicationContext).getString(R.string.backup_restoring))// Read before pauseAllDbWriters clears it, and outside it so a straggler timeout still resumes.trackingWasEnabled = DatabaseHelper.getInstance(reactApplicationContext)diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/BuildConfigModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/BuildConfigModule.ktindex 492017ce..75ef059c 100644--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/BuildConfigModule.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/BuildConfigModule.kt@@ -6,12 +6,17 @@package com.Colota.bridgeimport android.os.Build+import androidx.appcompat.app.AppCompatDelegate+import androidx.core.app.LocaleManagerCompat+import androidx.core.os.LocaleListCompatimport com.facebook.react.bridge.Argumentsimport com.facebook.react.bridge.Promiseimport com.facebook.react.bridge.ReactApplicationContextimport com.Colota.BuildConfig+import com.Colota.util.AppLanguageimport com.facebook.react.bridge.ReactContextBaseJavaModuleimport com.facebook.react.bridge.ReactMethod+import com.facebook.react.bridge.UiThreadUtilimport java.util.Localeclass BuildConfigModule(reactContext: ReactApplicationContext) :@@ -28,6 +33,51 @@ class BuildConfigModule(reactContext: ReactApplicationContext) :)}+ /** The picked language ("" while the app follows the system) and the language it runs in now. */+ @ReactMethod+ fun getAppLanguage(promise: Promise) {+ try {+ val picked = AppCompatDelegate.getApplicationLocales()[0]?.toLanguageTag() ?: ""+ promise.resolve(+ Arguments.createMap().apply {+ putString("picked", picked)+ putString("effective", effectiveLanguage(picked))+ }+ )+ } catch (e: Exception) {+ promise.reject("E_APP_LANGUAGE", e.message ?: "Could not read the app language", e)+ }+ }++ /** "" follows the system. */+ @ReactMethod+ fun setAppLanguage(tag: String, promise: Promise) {+ UiThreadUtil.runOnUiThread {+ try {+ val stored = withPhoneRegion(tag)+ AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(stored))+ AppLanguage.use(reactApplicationContext, stored)+ promise.resolve(effectiveLanguage(stored))+ } catch (e: Exception) {+ promise.reject("E_APP_LANGUAGE", e.message ?: "Could not change the app language", e)+ }+ }+ }++ // The pick names a language only; the phone's region keeps unit, clock and number defaults where they were.+ private fun withPhoneRegion(tag: String): String {+ if (tag.isEmpty()) return tag+ val picked = Locale.forLanguageTag(tag)+ val region = LocaleManagerCompat.getSystemLocales(reactApplicationContext)[0]?.country.orEmpty()+ if (picked.country.isNotEmpty() || region.isEmpty()) return tag+ return Locale.Builder().setLocale(picked).setRegion(region).build().toLanguageTag()+ }++ private fun effectiveLanguage(picked: String): String {+ val locale = if (picked.isEmpty()) LocaleManagerCompat.getSystemLocales(reactApplicationContext)[0] else Locale.forLanguageTag(picked)+ return (locale ?: Locale.getDefault()).toLanguageTag()+ }+/*** The wallpaper-derived tonal steps the theme reads, as `#RRGGBB`. Null below API 31, where* the framework has no such palette. Hex rather than PlatformColor: the theme concatenatesdiff --git a/apps/mobile/android/app/src/main/java/com/colota/export/AutoExportWorker.kt b/apps/mobile/android/app/src/main/java/com/colota/export/AutoExportWorker.ktindex 968e0ea0..027f1d14 100644--- a/apps/mobile/android/app/src/main/java/com/colota/export/AutoExportWorker.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/export/AutoExportWorker.kt@@ -20,6 +20,7 @@ import androidx.documentfile.provider.DocumentFileimport androidx.work.CoroutineWorkerimport androidx.work.ForegroundInfoimport androidx.work.WorkerParameters+import com.Colota.util.AppLanguageimport com.Colota.Rimport com.Colota.bridge.LocationServiceModuleimport com.Colota.data.DatabaseHelper@@ -57,12 +58,14 @@ class AutoExportWorker(private set}+ private val strings: Context get() = AppLanguage.context(appContext)+override suspend fun getForegroundInfo(): ForegroundInfo {ensureNotificationChannel()val notification = NotificationCompat.Builder(appContext, CHANNEL_ID).setSmallIcon(android.R.drawable.ic_menu_save)- .setContentTitle(appContext.getString(R.string.auto_export_title))- .setContentText(appContext.getString(R.string.auto_export_running))+ .setContentTitle(strings.getString(R.string.auto_export_title))+ .setContentText(strings.getString(R.string.auto_export_running)).setOngoing(true).build()return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {@@ -92,7 +95,7 @@ class AutoExportWorker(private suspend fun executeWork(isManualRun: Boolean): Result {if (runAttemptCount >= MAX_RETRIES) {AppLogger.e(TAG, "Auto-export failed after $MAX_RETRIES attempts, giving up")- showNotification(appContext.getString(R.string.auto_export_failed), appContext.getString(R.string.auto_export_gave_up))+ showNotification(strings.getString(R.string.auto_export_failed), strings.getString(R.string.auto_export_gave_up))return Result.failure()}@@ -163,7 +166,7 @@ class AutoExportWorker(if (rowCount == 0) {tempFile.delete()AppLogger.i(TAG, "No locations to export")- showNotification(appContext.getString(R.string.auto_export_title), appContext.getString(R.string.auto_export_nothing_new))+ showNotification(strings.getString(R.string.auto_export_title), strings.getString(R.string.auto_export_nothing_new))cleanupOldExports(dirUri, config)if (isManualRun) LocationServiceModule.sendAutoExportEvent(true, null, 0, null)return Result.success()@@ -187,8 +190,8 @@ class AutoExportWorker(AppLogger.i(TAG, "Auto-export complete: $savedName ($rowCount locations)")config.saveLastResult(db, savedName, rowCount)showNotification(- appContext.getString(R.string.auto_export_complete),- appContext.resources.getQuantityString(R.plurals.auto_export_done, rowCount, rowCount, savedName),+ strings.getString(R.string.auto_export_complete),+ strings.resources.getQuantityString(R.plurals.auto_export_done, rowCount, rowCount, savedName),dirUri)LocationServiceModule.sendAutoExportEvent(true, savedName, rowCount, null)@@ -200,7 +203,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "Directory permission lost",logMessage = "Auto-export failed - permission denied",- userMessage = appContext.getString(R.string.auto_export_permission_lost),+ userMessage = strings.getString(R.string.auto_export_permission_lost),retry = false)} catch (e: IllegalArgumentException) {@@ -208,7 +211,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "Invalid configuration: ${e.message}",logMessage = "Auto-export failed - invalid configuration",- userMessage = appContext.getString(R.string.auto_export_invalid_config, e.message.orEmpty()),+ userMessage = strings.getString(R.string.auto_export_invalid_config, e.message.orEmpty()),retry = false)} catch (e: DirectoryAccessException) {@@ -216,7 +219,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "Directory access failed: ${e.message}",logMessage = "Auto-export failed - directory access issue",- userMessage = appContext.getString(R.string.auto_export_directory_failed, e.message.orEmpty()),+ userMessage = strings.getString(R.string.auto_export_directory_failed, e.message.orEmpty()),retry = false)} catch (e: SQLException) {@@ -224,7 +227,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "Read failed: ${e.message}",logMessage = "Auto-export failed - database read, will retry",- userMessage = appContext.getString(R.string.auto_export_read_failed),+ userMessage = strings.getString(R.string.auto_export_read_failed),retry = true)} catch (e: IOException) {@@ -232,7 +235,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "IO error: ${e.message}",logMessage = "Auto-export failed - IO error, will retry",- userMessage = appContext.getString(R.string.auto_export_save_failed),+ userMessage = strings.getString(R.string.auto_export_save_failed),retry = true)} catch (e: Exception) {@@ -240,7 +243,7 @@ class AutoExportWorker(tempFile, config, db, e,error = "Export failed: ${e.message}",logMessage = "Auto-export failed",- userMessage = appContext.getString(R.string.auto_export_save_failed),+ userMessage = strings.getString(R.string.auto_export_save_failed),retry = true)}@@ -259,7 +262,7 @@ class AutoExportWorker(tempFile.delete()AppLogger.e(TAG, logMessage, e)config.saveLastError(db, error)- showNotification(appContext.getString(R.string.auto_export_failed), userMessage)+ showNotification(strings.getString(R.string.auto_export_failed), userMessage)LocationServiceModule.sendAutoExportEvent(false, null, 0, error)return if (retry) Result.retry() else Result.failure()}@@ -353,10 +356,10 @@ class AutoExportWorker(val nm = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManagerval channel = NotificationChannel(CHANNEL_ID,- appContext.getString(R.string.channel_auto_export),+ strings.getString(R.string.channel_auto_export),NotificationManager.IMPORTANCE_LOW).apply {- description = appContext.getString(R.string.channel_auto_export_description)+ description = strings.getString(R.string.channel_auto_export_description)}nm.createNotificationChannel(channel)}diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/BatteryRecoveryWorker.kt b/apps/mobile/android/app/src/main/java/com/colota/service/BatteryRecoveryWorker.ktindex 05a285cf..f744b218 100644--- a/apps/mobile/android/app/src/main/java/com/colota/service/BatteryRecoveryWorker.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/service/BatteryRecoveryWorker.kt@@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompatimport androidx.work.CoroutineWorkerimport androidx.work.ForegroundInfoimport androidx.work.WorkerParameters+import com.Colota.util.AppLanguageimport com.Colota.Rimport com.Colota.data.DatabaseHelperimport com.Colota.data.SettingsKeys@@ -38,13 +39,15 @@ class BatteryRecoveryWorker(private const val FOREGROUND_NOTIFICATION_ID = 9003}+ private val strings: Context get() = AppLanguage.context(appContext)+override suspend fun getForegroundInfo(): ForegroundInfo {ensureNotificationChannel()val notification = NotificationCompat.Builder(appContext, CHANNEL_ID).setSmallIcon(R.drawable.ic_notification).setColor(NotificationHelper.ICON_COLOR)- .setContentTitle(appContext.getString(R.string.battery_recovery_title))- .setContentText(appContext.getString(R.string.battery_recovery_text))+ .setContentTitle(strings.getString(R.string.battery_recovery_title))+ .setContentText(strings.getString(R.string.battery_recovery_text)).setOngoing(true).build()return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {@@ -116,10 +119,10 @@ class BatteryRecoveryWorker(val nm = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManagerval channel = NotificationChannel(CHANNEL_ID,- appContext.getString(R.string.channel_battery_recovery),+ strings.getString(R.string.channel_battery_recovery),NotificationManager.IMPORTANCE_LOW).apply {- description = appContext.getString(R.string.channel_battery_recovery_description)+ description = strings.getString(R.string.channel_battery_recovery_description)}nm.createNotificationChannel(channel)}diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/NotificationHelper.kt b/apps/mobile/android/app/src/main/java/com/colota/service/NotificationHelper.ktindex e51d0465..03c11b15 100644--- a/apps/mobile/android/app/src/main/java/com/colota/service/NotificationHelper.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/service/NotificationHelper.kt@@ -11,6 +11,7 @@ import android.content.Intentimport android.os.Buildimport androidx.annotation.StringResimport androidx.core.app.NotificationCompat+import com.Colota.util.AppLanguageimport com.Colota.MainActivityimport com.Colota.R@@ -54,6 +55,8 @@ class NotificationHelper(private var lastKey: String? = null+ private val strings: Context get() = AppLanguage.context(context)+/** From Android 12 the collapsed row shows the app name only when there is no title. */private val headerless = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S@@ -69,20 +72,20 @@ class NotificationHelper(fun createChannel() {val channel = NotificationChannel(CHANNEL_ID,- context.getString(R.string.channel_tracking),+ strings.getString(R.string.channel_tracking),NotificationManager.IMPORTANCE_LOW).apply {- description = context.getString(R.string.channel_tracking_description)+ description = strings.getString(R.string.channel_tracking_description)setShowBadge(false)}notificationManager.createNotificationChannel(channel)val stoppedChannel = NotificationChannel(STOPPED_CHANNEL_ID,- context.getString(R.string.channel_stopped),+ strings.getString(R.string.channel_stopped),NotificationManager.IMPORTANCE_DEFAULT).apply {- description = context.getString(R.string.channel_stopped_description)+ description = strings.getString(R.string.channel_stopped_description)setShowBadge(true)}notificationManager.createNotificationChannel(stoppedChannel)@@ -126,8 +129,8 @@ class NotificationHelper(PendingIntent.FLAG_IMMUTABLE)- val title = context.getString(R.string.stopped_title)- val text = context.getString(reason.text)+ val title = strings.getString(R.string.stopped_title)+ val text = strings.getString(reason.text)return NotificationCompat.Builder(context,if (unexpected) STOPPED_CHANNEL_ID else CHANNEL_ID@@ -165,9 +168,9 @@ class NotificationHelper(}private fun str(@StringRes id: Int, vararg args: Any): String =- if (args.isEmpty()) context.getString(id) else context.getString(id, *args)+ if (args.isEmpty()) strings.getString(id) else strings.getString(id, *args)- private fun count(id: Int, n: Int): String = context.resources.getQuantityString(id, n, n)+ private fun count(id: Int, n: Int): String = strings.resources.getQuantityString(id, n, n)private fun pauseDetail(input: StatusInput): String = when {input.isWifiPaused -> str(R.string.status_pause_wifi)diff --git a/apps/mobile/android/app/src/main/java/com/colota/triggers/TrackingControlReceiver.kt b/apps/mobile/android/app/src/main/java/com/colota/triggers/TrackingControlReceiver.ktindex 48f5d898..918d17de 100644--- a/apps/mobile/android/app/src/main/java/com/colota/triggers/TrackingControlReceiver.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/triggers/TrackingControlReceiver.kt@@ -11,6 +11,7 @@ import android.content.Intentimport android.os.Handlerimport android.os.Looperimport android.widget.Toast+import com.Colota.util.AppLanguageimport com.Colota.Rimport com.Colota.service.NotificationHelperimport com.Colota.util.AppLogger@@ -53,13 +54,13 @@ class TrackingControlReceiver : BroadcastReceiver() {private fun handleStart(context: Context) {AppLogger.d(TAG, "Broadcast: start tracking")TrackingControl.start(context, "Started via automation intent")- toastOnMain(context, context.getString(R.string.toast_tracking_started))+ toastOnMain(context, AppLanguage.context(context).getString(R.string.toast_tracking_started))}private fun handleStop(context: Context) {AppLogger.d(TAG, "Broadcast: stop tracking")TrackingControl.stop(context, NotificationHelper.StopReason.AUTOMATION)- toastOnMain(context, context.getString(R.string.toast_tracking_stopped))+ toastOnMain(context, AppLanguage.context(context).getString(R.string.toast_tracking_stopped))}private fun toastOnMain(context: Context, message: String) {diff --git a/apps/mobile/android/app/src/main/java/com/colota/util/AppLanguage.kt b/apps/mobile/android/app/src/main/java/com/colota/util/AppLanguage.ktnew file mode 100644index 00000000..48b771f0--- /dev/null+++ b/apps/mobile/android/app/src/main/java/com/colota/util/AppLanguage.kt@@ -0,0 +1,33 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++package com.Colota.util++import android.content.Context+import android.content.res.Configuration+import android.os.Build+import android.os.LocaleList+import androidx.core.content.ContextCompat++/** Native text is read through this: below Android 13 the in-app language reaches AppCompat activities only. */+object AppLanguage {+ @Volatile private var cached: Context? = null++ fun context(base: Context): Context {+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) return base+ return cached ?: ContextCompat.getContextForLanguage(base.applicationContext).also { cached = it }+ }++ // Built from the tag, because AppCompat writes the choice to its file on a background thread.+ fun use(base: Context, tag: String) {+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) return+ val app = base.applicationContext+ cached = if (tag.isEmpty()) {+ app+ } else {+ app.createConfigurationContext(Configuration(app.resources.configuration).apply { setLocales(LocaleList.forLanguageTags(tag)) })+ }+ }+}diff --git a/apps/mobile/android/app/src/main/res/values/strings.xml b/apps/mobile/android/app/src/main/res/values/strings.xmlindex fc65cd2e..ad7d232b 100644--- a/apps/mobile/android/app/src/main/res/values/strings.xml+++ b/apps/mobile/android/app/src/main/res/values/strings.xml@@ -1,5 +1,5 @@<resources>- <string name="app_name">Colota</string>+ <string name="app_name" translatable="false">Colota</string><string name="shortcut_start_short">Start</string><string name="shortcut_start_long">Start Tracking</string><string name="shortcut_stop_short">Stop</string>diff --git a/apps/mobile/android/app/src/main/res/xml/locales_config.xml b/apps/mobile/android/app/src/main/res/xml/locales_config.xmlnew file mode 100644index 00000000..5de0247f--- /dev/null+++ b/apps/mobile/android/app/src/main/res/xml/locales_config.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- One entry per catalog in src/i18n/locales, or Android's per-app language list offers a language the app lacks. -->+<locale-config xmlns:android="http://schemas.android.com/apk/res/android">+ <locale android:name="en" />+</locale-config>diff --git a/apps/mobile/android/app/src/test/java/com/Colota/bridge/BuildConfigModuleTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/bridge/BuildConfigModuleTest.ktindex 1f1c2cb4..84865d33 100644--- a/apps/mobile/android/app/src/test/java/com/Colota/bridge/BuildConfigModuleTest.kt+++ b/apps/mobile/android/app/src/test/java/com/Colota/bridge/BuildConfigModuleTest.kt@@ -6,6 +6,12 @@package com.Colota.bridgeimport android.content.Context+import android.os.Looper+import androidx.appcompat.app.AppCompatActivity+import androidx.appcompat.app.AppCompatDelegate+import androidx.core.os.LocaleListCompat+import com.Colota.R+import com.Colota.util.AppLanguageimport androidx.test.core.app.ApplicationProviderimport com.facebook.react.bridge.Argumentsimport com.facebook.react.bridge.BridgeReactContext@@ -16,6 +22,7 @@ import io.mockk.everyimport io.mockk.mockkimport io.mockk.mockkStaticimport io.mockk.unmockkStatic+import java.util.Localeimport org.junit.Afterimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertNull@@ -23,7 +30,9 @@ import org.junit.Assert.assertTrueimport org.junit.Beforeimport org.junit.Testimport org.junit.runner.RunWith+import org.robolectric.Robolectricimport org.robolectric.RobolectricTestRunner+import org.robolectric.Shadows.shadowOfimport org.robolectric.annotation.Config@RunWith(RobolectricTestRunner::class)@@ -54,6 +63,9 @@ class BuildConfigModuleTest {@Afterfun tearDown() {unmockkStatic(Arguments::class)+ // AppCompat keeps the choice in a static, which would leak into the next test.+ AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList())+ AppLanguage.use(ApplicationProvider.getApplicationContext(), "")}@Test@@ -80,6 +92,53 @@ class BuildConfigModuleTest {assertNull(resolved)}+ @Test+ fun `a picked language reads back as picked and in use`() {+ Robolectric.buildActivity(AppCompatActivity::class.java).apply { get().setTheme(R.style.AppTheme) }.setup()++ module.setAppLanguage("de", capturingPromise())+ shadowOf(Looper.getMainLooper()).idle()+ assertEquals("de-US", resolved)++ module.getAppLanguage(capturingPromise())+ assertEquals("de-US", (resolved as WritableMap).getString("picked"))+ assertEquals("de-US", (resolved as WritableMap).getString("effective"))+ }++ // An en-US phone picking English must keep miles and the 12-hour clock, which a bare "en" would drop.+ @Test+ fun `a pick keeps the phone's region`() {+ Robolectric.buildActivity(AppCompatActivity::class.java).apply { get().setTheme(R.style.AppTheme) }.setup()++ module.setAppLanguage("en", capturingPromise())+ shadowOf(Looper.getMainLooper()).idle()++ assertEquals("en-US", resolved)+ }++ @Test+ fun `an empty tag hands the language back to the phone`() {+ Robolectric.buildActivity(AppCompatActivity::class.java).apply { get().setTheme(R.style.AppTheme) }.setup()+ module.setAppLanguage("de", capturingPromise())+ module.setAppLanguage("", capturingPromise())+ shadowOf(Looper.getMainLooper()).idle()++ module.getAppLanguage(capturingPromise())+ assertEquals("", (resolved as WritableMap).getString("picked"))+ assertEquals(Locale.getDefault().toLanguageTag(), (resolved as WritableMap).getString("effective"))+ }++ // Services and workers read native text through this, and below 13 nothing else carries the choice to them.+ @Test+ @Config(sdk = [30])+ fun `below Android 13 native text follows the pick at once`() {+ val app: Context = ApplicationProvider.getApplicationContext()+ module.setAppLanguage("de", capturingPromise())+ shadowOf(Looper.getMainLooper()).idle()++ assertEquals("de", AppLanguage.context(app).resources.configuration.locales[0].language)+ }+private fun capturingPromise(): Promise {val promise = mockk<Promise>()every { promise.resolve(any()) } answers { resolved = firstArg<Any?>() }diff --git a/apps/mobile/src/hooks/useLanguageChoice.ts b/apps/mobile/src/hooks/useLanguageChoice.tsnew file mode 100644index 00000000..aa2f0187--- /dev/null+++ b/apps/mobile/src/hooks/useLanguageChoice.ts@@ -0,0 +1,29 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import { useCallback, useEffect, useState } from "react"+import { AppState } from "react-native"+import { useFocusEffect } from "@react-navigation/native"+import { getLanguageChoice, type LanguageChoice } from "../i18n/language"++/** Re-read on every return to the app, because Android's own App languages page can change it. */+export function useLanguageChoice(): [LanguageChoice | null, (choice: LanguageChoice) => void] {+ const [choice, setChoice] = useState<LanguageChoice | null>(null)++ useFocusEffect(+ useCallback(() => {+ getLanguageChoice().then(setChoice)+ }, [])+ )++ useEffect(() => {+ const sub = AppState.addEventListener("change", (state) => {+ if (state === "active") getLanguageChoice().then(setChoice)+ })+ return () => sub.remove()+ }, [])++ return [choice, setChoice]+}diff --git a/apps/mobile/src/i18n/__tests__/language.test.ts b/apps/mobile/src/i18n/__tests__/language.test.tsnew file mode 100644index 00000000..66f2b6e6--- /dev/null+++ b/apps/mobile/src/i18n/__tests__/language.test.ts@@ -0,0 +1,75 @@+import i18next from "i18next"++const fs: {+ readFileSync: (file: string, encoding: "utf8") => string+ readdirSync: (dir: string) => string[]+} = require("fs")+const path: { join: (...parts: string[]) => string } = require("path")++const mockGetAppLanguage = jest.fn()++jest.mock("../../services/NativeLocationService", () => ({+ __esModule: true,+ default: {+ getAppLanguage: () => mockGetAppLanguage(),+ setAppLanguage: jest.fn()+ }+}))++import { syncLanguage } from "../language"+import { I18N_OPTIONS, SUPPORTED_LANGUAGES } from "../options"++describe("syncLanguage", () => {+ beforeAll(async () => {+ await i18next.init({ ...I18N_OPTIONS, lng: "en" })+ })++ // Android's App languages page changes the app locale without the picker ever running.+ it("moves the catalog to the language Android now runs the app in", async () => {+ await i18next.changeLanguage("xx")+ mockGetAppLanguage.mockResolvedValue({ picked: "", effective: "en-US" })++ await syncLanguage()++ expect(i18next.language).toBe("en")+ })++ it("leaves the catalog alone when the language is already right or cannot be read", async () => {+ await i18next.changeLanguage("en")+ const change = jest.spyOn(i18next, "changeLanguage")+ mockGetAppLanguage.mockResolvedValueOnce({ picked: "", effective: "en-GB" }).mockResolvedValueOnce(null)++ await syncLanguage()+ await syncLanguage()++ expect(change).not.toHaveBeenCalled()+ change.mockRestore()+ })+})++// Android offers every locale listed here under App languages, so a missing catalog would be selectable.+it("lists exactly the shipped catalogs in locales_config.xml", () => {+ const xml = fs.readFileSync(path.join(__dirname, "../../../android/app/src/main/res/xml/locales_config.xml"), "utf8")+ const listed = [...xml.matchAll(/<locale android:name="([^"]+)"/g)].map((m) => m[1]).sort()+ expect(listed).toEqual([...SUPPORTED_LANGUAGES].sort())+})++// A translator's file is checked even before it is registered, so a broken one fails its pull request.+describe("every catalog in locales/", () => {+ const dir = path.join(__dirname, "../locales")+ const en = JSON.parse(fs.readFileSync(path.join(dir, "en.json"), "utf8")) as Record<string, string>+ const placeholders = (text: string) => (text.match(/\{\{\w+\}\}/g) ?? []).sort()+ const catalogs = fs.readdirSync(dir).filter((f: string) => f.endsWith(".json") && f !== "en.json")++ it.each(catalogs.length ? catalogs : ["(none yet)"])(+ "%s uses only English keys and keeps their placeholders",+ (file) => {+ if (file === "(none yet)") return+ const catalog = JSON.parse(fs.readFileSync(path.join(dir, file), "utf8")) as Record<string, string>+ for (const [key, text] of Object.entries(catalog)) {+ expect(en).toHaveProperty([key])+ expect(placeholders(text)).toEqual(placeholders(en[key]))+ }+ }+ )+})diff --git a/apps/mobile/src/i18n/index.ts b/apps/mobile/src/i18n/index.tsindex 82e44602..2068b142 100644--- a/apps/mobile/src/i18n/index.ts+++ b/apps/mobile/src/i18n/index.ts@@ -6,17 +6,11 @@import i18next from "i18next"import NativeLocationService from "../services/NativeLocationService"import { logger } from "../utils/logger"-import { I18N_OPTIONS, FALLBACK_LANGUAGE, SUPPORTED_LANGUAGES, type SupportedLanguage } from "./options"+import { I18N_OPTIONS, SUPPORTED_LANGUAGES, resolveLanguage, type SupportedLanguage } from "./options"export { SUPPORTED_LANGUAGES }export { t } from "./t"-/** The device tag carries a region, the catalogs do not. */-function resolveLanguage(tag: string | undefined): SupportedLanguage {- const base = (tag ?? "").split("-")[0].toLowerCase()- return (SUPPORTED_LANGUAGES as readonly string[]).includes(base) ? (base as SupportedLanguage) : FALLBACK_LANGUAGE-}-/** Plurals beyond one/other, which the English fallback gets wrong. */const COMPLEX_PLURAL_LANGUAGES: readonly string[] = ["pl", "ru", "cs", "ar", "uk", "hr", "lt", "sk"]diff --git a/apps/mobile/src/i18n/language.ts b/apps/mobile/src/i18n/language.tsnew file mode 100644index 00000000..9ee3a9e9--- /dev/null+++ b/apps/mobile/src/i18n/language.ts@@ -0,0 +1,30 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import i18next from "i18next"+import NativeLocationService from "../services/NativeLocationService"+import { resolveLanguage, type SupportedLanguage } from "./options"++export type LanguageChoice = SupportedLanguage | "system"++/** A failed read shows System default, which is what the app falls back to anyway. */+export async function getLanguageChoice(): Promise<LanguageChoice> {+ const language = await NativeLocationService.getAppLanguage()+ return language?.picked ? resolveLanguage(language.picked) : "system"+}++/** Follows a language change made outside the picker; a failed read keeps the language in use. */+export async function syncLanguage(): Promise<void> {+ const current = await NativeLocationService.getAppLanguage()+ if (!current) return+ const language = resolveLanguage(current.effective)+ if (language !== i18next.language) await i18next.changeLanguage(language)+}++/** Native keeps the choice, and i18next switches now so the screens follow without a restart. */+export async function setLanguageChoice(choice: LanguageChoice): Promise<void> {+ const effective = await NativeLocationService.setAppLanguage(choice === "system" ? "" : choice)+ await i18next.changeLanguage(resolveLanguage(effective))+}diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.jsonindex 6248f7f6..5390986d 100644--- a/apps/mobile/src/i18n/locales/en.json+++ b/apps/mobile/src/i18n/locales/en.json@@ -43,6 +43,7 @@"screen.logPreview": "Log preview","screen.backupRestore": "Backup & restore","screen.appearance": "Appearance",+ "screen.language": "Language","screen.connection": "Connection","screen.trackingSync": "Tracking & sync","tab.dashboard": "Dashboard",@@ -1238,5 +1239,7 @@"error.unexpected": "An unexpected error occurred","error.retry": "Try again","about.copyright": "Copyright © 2026 Max Dietrich and contributors. Colota is free software, with no warranty; the License row above has the terms.",- "log.delete.subCarries": "Removes {{size}}. Recording carries on into a new file."+ "log.delete.subCarries": "Removes {{size}}. Recording carries on into a new file.",+ "language.system": "System default",+ "language.changeFailed": "Could not change the language."}diff --git a/apps/mobile/src/i18n/options.ts b/apps/mobile/src/i18n/options.tsindex 33ff1e8b..80221ce5 100644--- a/apps/mobile/src/i18n/options.ts+++ b/apps/mobile/src/i18n/options.ts@@ -16,11 +16,22 @@ export type TranslationKey = CatalogKey | PluralBase<CatalogKey>export const FALLBACK_LANGUAGE: SupportedLanguage = "en"+/** Each language in its own words, so a reader finds theirs whatever the app is set to. */+export const LANGUAGE_NAMES: Record<SupportedLanguage, string> = { en: "English" }++/** The device tag carries a region, the catalogs do not. */+export function resolveLanguage(tag: string | undefined): SupportedLanguage {+ const base = (tag ?? "").split("-")[0].toLowerCase()+ return (SUPPORTED_LANGUAGES as readonly string[]).includes(base) ? (base as SupportedLanguage) : FALLBACK_LANGUAGE+}+/** Side-effect free so `jest.setup.js` can share it. Inline resources keep `init()` synchronous. */export const I18N_OPTIONS = {fallbackLng: FALLBACK_LANGUAGE,resources: { en: { translation: en } },interpolation: { escapeValue: false },returnNull: false,+ // An emptied value in a translation shows the English, not a blank label.+ returnEmptyString: false,keySeparator: false as const}diff --git a/apps/mobile/src/screens/AppearanceScreen.tsx b/apps/mobile/src/screens/AppearanceScreen.tsxindex d84e75e2..0aa46a7d 100644--- a/apps/mobile/src/screens/AppearanceScreen.tsx+++ b/apps/mobile/src/screens/AppearanceScreen.tsx@@ -8,6 +8,8 @@ import { StyleSheet, View, ScrollView } from "react-native"import { ScreenProps } from "../types/global"import { useTheme, type ThemePreference } from "../hooks/useTheme"import { useTranslation } from "../i18n/useTranslation"+import { LANGUAGE_NAMES } from "../i18n/options"+import { useLanguageChoice } from "../hooks/useLanguageChoice"import NativeLocationService from "../services/NativeLocationService"import {Button,@@ -30,7 +32,7 @@ import { space } from "../constants"type StyleKey = "mapStyleUrlLight" | "mapStyleUrlDark"-export function AppearanceScreen({}: ScreenProps) {+export function AppearanceScreen({ navigation }: ScreenProps) {const {preference,setPreference,@@ -53,6 +55,14 @@ export function AppearanceScreen({}: ScreenProps) {const [lightError, setLightError] = useState<string | undefined>()const [darkError, setDarkError] = useState<string | undefined>()const [showMapTileServer, setShowMapTileServer] = useState(false)+ const [languageChoice] = useLanguageChoice()++ const languageLabel =+ languageChoice === null+ ? undefined+ : languageChoice === "system"+ ? t("language.system")+ : LANGUAGE_NAMES[languageChoice]const selectUnitSystem = useCallback(async (value: UnitSystem) => {@@ -206,6 +216,15 @@ export function AppearanceScreen({}: ScreenProps) {<Divider tight />+ <ListItem+ testID="nav-language"+ label={t("screen.language")}+ sub={languageLabel}+ onPress={() => navigation.navigate("Language")}+ />++ <Divider tight />+<ListItemtestID="map-tile-server-toggle"label={t("appearance.mapTileServer")}diff --git a/apps/mobile/src/screens/LanguageScreen.tsx b/apps/mobile/src/screens/LanguageScreen.tsxnew file mode 100644index 00000000..81b51504--- /dev/null+++ b/apps/mobile/src/screens/LanguageScreen.tsx@@ -0,0 +1,73 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React, { useRef } from "react"+import { ScrollView, StyleSheet, View } from "react-native"+import { ScreenProps } from "../types/global"+import { Card, Container, RadioRow } from "../components"+import { useTranslation } from "../i18n/useTranslation"+import { t as translate } from "../i18n/t"+import { LANGUAGE_NAMES, SUPPORTED_LANGUAGES } from "../i18n/options"+import { setLanguageChoice, type LanguageChoice } from "../i18n/language"+import { useLanguageChoice } from "../hooks/useLanguageChoice"+import { showAlert } from "../services/modalService"+import { logger } from "../utils/logger"+import { space } from "../constants"++export function LanguageScreen({}: ScreenProps) {+ const { t } = useTranslation()+ const [choice, setChoice] = useLanguageChoice()+ const busy = useRef(false)++ const choose = async (next: LanguageChoice) => {+ if (busy.current || choice === null || next === choice) return+ const previous = choice+ busy.current = true+ setChoice(next)+ try {+ await setLanguageChoice(next)+ } catch (err) {+ logger.error("[LanguageScreen] Failed to change the language:", err)+ setChoice(previous)+ showAlert(translate("common.error"), translate("language.changeFailed"), "error")+ } finally {+ busy.current = false+ }+ }++ const options: { value: LanguageChoice; label: string }[] = [+ { value: "system", label: t("language.system") },+ ...SUPPORTED_LANGUAGES.map((lang) => ({ value: lang, label: LANGUAGE_NAMES[lang] }))+ ]++ return (+ <Container>+ <ScrollView contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false}>+ <Card rows>+ <View accessibilityRole="radiogroup">+ {options.map(({ value, label }) => (+ <RadioRow+ key={value}+ testID={`language-${value}`}+ label={label}+ selected={choice === value}+ disabled={choice === null}+ onPress={() => choose(value)}+ />+ ))}+ </View>+ </Card>+ </ScrollView>+ </Container>+ )+}++const styles = StyleSheet.create({+ scrollContent: {+ paddingHorizontal: space.lg,+ paddingTop: space.lg,+ paddingBottom: space.xxl+ }+})diff --git a/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsx b/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsxindex e4a2353a..a76776a8 100644--- a/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsx+++ b/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsx@@ -1,5 +1,5 @@import React from "react"-import { render, fireEvent, waitFor } from "@testing-library/react-native"+import { act, render, fireEvent, waitFor } from "@testing-library/react-native"// --- Mocks ---@@ -20,6 +20,17 @@ jest.mock("../../hooks/useTheme", () => ({})}))+jest.mock("@react-navigation/native", () => ({+ useFocusEffect: (cb: () => (() => void) | void) => {+ const R = require("react")+ R.useEffect(() => {+ const cleanup = cb()+ return typeof cleanup === "function" ? cleanup : undefined+ }, [cb])+ }+}))++const mockGetAppLanguage = jest.fn().mockResolvedValue({ picked: "", effective: "de-DE" })const mockSaveSetting = jest.fn().mockResolvedValue(undefined)const mockGetSetting = jest.fn().mockResolvedValue(null)@@ -28,7 +39,8 @@ jest.mock("../../services/NativeLocationService", () => ({default: {saveSetting: (key: string, value: string) => mockSaveSetting(key, value),getSetting: (key: string) => mockGetSetting(key),- getBuildConfig: () => ({ APP_LANGUAGE: "en-GB" })+ getBuildConfig: () => ({ APP_LANGUAGE: "en-GB" }),+ getAppLanguage: () => mockGetAppLanguage()}}))@@ -292,4 +304,25 @@ describe("AppearanceScreen", () => {await waitFor(() => expect(custom.getByTestId("map-style-reset-btn")).toBeTruthy())})++ it("opens the Language screen from a row that names the current choice", async () => {+ const { getByTestId, findByText } = render(<AppearanceScreen navigation={mockNavigation} />)++ expect(await findByText("System default")).toBeTruthy()+ fireEvent.press(getByTestId("nav-language"))+ expect(mockNavigation.navigate).toHaveBeenCalledWith("Language")+ })++ // Android's App languages page changes the choice while Colota sits in the background.+ it("re-reads the language row when the app comes back to the foreground", async () => {+ const { AppState } = require("react-native")+ const { findByText } = render(<AppearanceScreen navigation={mockNavigation} />)+ expect(await findByText("System default")).toBeTruthy()++ mockGetAppLanguage.mockResolvedValueOnce({ picked: "en", effective: "en" })+ const onChange = (AppState.addEventListener as jest.Mock).mock.calls.at(-1)[1]+ await act(async () => onChange("active"))++ expect(await findByText("English")).toBeTruthy()+ })})diff --git a/apps/mobile/src/screens/__tests__/LanguageScreen.test.tsx b/apps/mobile/src/screens/__tests__/LanguageScreen.test.tsxnew file mode 100644index 00000000..217b3f37--- /dev/null+++ b/apps/mobile/src/screens/__tests__/LanguageScreen.test.tsx@@ -0,0 +1,119 @@+import React from "react"+import { render, fireEvent, waitFor } from "@testing-library/react-native"+import i18next from "i18next"++jest.mock("@react-navigation/native", () => ({+ useFocusEffect: (cb: () => (() => void) | void) => {+ const R = require("react")+ R.useEffect(() => {+ const cleanup = cb()+ return typeof cleanup === "function" ? cleanup : undefined+ }, [cb])+ }+}))++const mockGetAppLanguage = jest.fn()+const mockSetAppLanguage = jest.fn()+const mockShowAlert = jest.fn()++jest.mock("../../services/NativeLocationService", () => ({+ __esModule: true,+ default: {+ getAppLanguage: () => mockGetAppLanguage(),+ setAppLanguage: (tag: string) => mockSetAppLanguage(tag)+ }+}))++jest.mock("../../services/modalService", () => ({+ showAlert: (...args: unknown[]) => mockShowAlert(...args)+}))++jest.mock("../../utils/logger", () => ({ logger: { error: jest.fn(), warn: jest.fn(), debug: jest.fn() } }))++jest.mock("../../components", () => {+ const R = require("react")+ const { View, Text, Pressable } = require("react-native")+ return {+ Container: ({ children }: any) => R.createElement(View, null, children),+ Card: ({ children }: any) => R.createElement(View, null, children),+ RadioRow: ({ label, selected, onPress, disabled, testID }: any) =>+ R.createElement(+ Pressable,+ { testID, onPress, disabled, accessibilityState: { checked: selected, disabled } },+ R.createElement(Text, null, label)+ )+ }+})++import { LanguageScreen } from "../LanguageScreen"++describe("LanguageScreen", () => {+ beforeEach(() => {+ jest.clearAllMocks()+ mockGetAppLanguage.mockResolvedValue({ picked: "", effective: "de-DE" })+ mockSetAppLanguage.mockResolvedValue("en-GB")+ })++ it("offers System default and every catalog, each language named in its own words", async () => {+ const { findByText, getByText } = render(<LanguageScreen navigation={{} as any} />)++ expect(await findByText("System default")).toBeTruthy()+ expect(getByText("English")).toBeTruthy()+ })++ // i18next has to switch too, or the screens keep the old language until the next cold start.+ it("stores a pick natively and switches the catalog at once", async () => {+ const change = jest.spyOn(i18next, "changeLanguage")+ const { getByTestId } = render(<LanguageScreen navigation={{} as any} />)+ await waitFor(() => expect(getByTestId("language-en").props.accessibilityState.disabled).toBe(false))++ fireEvent.press(getByTestId("language-en"))++ await waitFor(() => expect(mockSetAppLanguage).toHaveBeenCalledWith("en"))+ await waitFor(() => expect(change).toHaveBeenCalledWith("en"))+ expect(getByTestId("language-en").props.accessibilityState.checked).toBe(true)+ change.mockRestore()+ })++ it("sends an empty tag for System default and shows the phone's language, or English when there is no catalog for it", async () => {+ mockGetAppLanguage.mockResolvedValue({ picked: "en", effective: "en" })+ mockSetAppLanguage.mockResolvedValue("fr-FR")+ const change = jest.spyOn(i18next, "changeLanguage")+ const { getByTestId } = render(<LanguageScreen navigation={{} as any} />)+ await waitFor(() => expect(getByTestId("language-en").props.accessibilityState.checked).toBe(true))++ fireEvent.press(getByTestId("language-system"))++ await waitFor(() => expect(mockSetAppLanguage).toHaveBeenCalledWith(""))+ await waitFor(() => expect(change).toHaveBeenCalledWith("en"))+ change.mockRestore()+ })++ it("puts the previous choice back and says so when native refuses", async () => {+ mockSetAppLanguage.mockRejectedValue(new Error("nope"))+ const change = jest.spyOn(i18next, "changeLanguage")+ const { getByTestId } = render(<LanguageScreen navigation={{} as any} />)+ await waitFor(() => expect(getByTestId("language-system").props.accessibilityState.checked).toBe(true))++ fireEvent.press(getByTestId("language-en"))++ await waitFor(() => expect(mockShowAlert).toHaveBeenCalledWith("Error", "Could not change the language.", "error"))+ expect(getByTestId("language-system").props.accessibilityState.checked).toBe(true)+ expect(change).not.toHaveBeenCalled()+ change.mockRestore()+ })++ it("ignores a second tap while the first switch is still running", async () => {+ let finish: (tag: string) => void = () => {}+ mockSetAppLanguage.mockImplementation(() => new Promise((resolve) => (finish = resolve)))+ const { getByTestId } = render(<LanguageScreen navigation={{} as any} />)+ await waitFor(() => expect(getByTestId("language-en").props.accessibilityState.disabled).toBe(false))++ fireEvent.press(getByTestId("language-en"))+ fireEvent.press(getByTestId("language-system"))+ finish("en")++ await waitFor(() => expect(getByTestId("language-en").props.accessibilityState.disabled).toBe(false))+ expect(mockSetAppLanguage).toHaveBeenCalledTimes(1)+ })+})diff --git a/apps/mobile/src/screens/index.ts b/apps/mobile/src/screens/index.tsindex 164d20d0..5d5a314a 100644--- a/apps/mobile/src/screens/index.ts+++ b/apps/mobile/src/screens/index.ts@@ -21,6 +21,7 @@ export { TrackingProfilesScreen } from "./TrackingProfilesScreen"export { ProfileEditorScreen } from "./ProfileEditorScreen"export { AboutScreen } from "./AboutScreen"export { AppearanceScreen } from "./AppearanceScreen"+export { LanguageScreen } from "./LanguageScreen"export { ConnectionScreen } from "./ConnectionScreen"export { TrackingSyncScreen } from "./TrackingSyncScreen"export { SetupImportScreen } from "./SetupImportScreen"diff --git a/apps/mobile/src/services/NativeLocationService.ts b/apps/mobile/src/services/NativeLocationService.tsindex 86ad1176..7ef49a8f 100644--- a/apps/mobile/src/services/NativeLocationService.ts+++ b/apps/mobile/src/services/NativeLocationService.ts@@ -733,6 +733,18 @@ class NativeLocationService {return BuildConfigModule}+ /** `picked` is "" while the app follows the system; `effective` is the language it runs in. Null when unreadable. */+ static async getAppLanguage(): Promise<{ picked: string; effective: string } | null> {+ if (!BuildConfigModule) return null+ return this.safeExecute(() => BuildConfigModule.getAppLanguage(), null, "Failed to read the app language")+ }++ /** "" follows the system. Resolves with the tag of the language the app now runs in. */+ static async setAppLanguage(tag: string): Promise<string> {+ if (!BuildConfigModule) throw new Error("BuildConfigModule not available")+ return BuildConfigModule.setAppLanguage(tag)+ }+/*** The wallpaper-derived tonal steps, or null below API 31 and whenever the map is not the* complete set the theme reads.diff --git a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts b/apps/mobile/src/services/__tests__/NativeLocationService.test.tsindex a00b170f..f9c4b2da 100644--- a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts+++ b/apps/mobile/src/services/__tests__/NativeLocationService.test.ts@@ -90,7 +90,9 @@ jest.mock("react-native", () => ({VERSION_NAME: "1.0.0",VERSION_CODE: 1,FLAVOR: "gms",- getSystemPalette: jest.fn().mockResolvedValue(null)+ getSystemPalette: jest.fn().mockResolvedValue(null),+ getAppLanguage: jest.fn().mockResolvedValue({ picked: "de", effective: "de" }),+ setAppLanguage: jest.fn().mockResolvedValue("de-DE")}}}))@@ -337,6 +339,17 @@ describe("NativeLocationService", () => {})})+ describe("app language", () => {+ it("reads the picked language and the one in use", async () => {+ await expect(NativeLocationService.getAppLanguage()).resolves.toEqual({ picked: "de", effective: "de" })+ })++ it("reads as nothing when native fails, so the screen shows System default and the catalog stays put", async () => {+ ;(NativeModules.BuildConfigModule.getAppLanguage as jest.Mock).mockRejectedValueOnce(new Error("x"))+ await expect(NativeLocationService.getAppLanguage()).resolves.toBeNull()+ })+ })+describe("getSystemPalette", () => {const palette = {accent1_100: "#D6E3FF",diff --git a/apps/mobile/src/types/navigation.ts b/apps/mobile/src/types/navigation.tsindex fd4f1d8e..52bbca06 100644--- a/apps/mobile/src/types/navigation.ts+++ b/apps/mobile/src/types/navigation.ts@@ -15,6 +15,7 @@ export type RootStackParamList = {Connection: undefined"Tracking & Sync": undefinedAppearance: undefined+ Language: undefined"Request Format": { template?: ApiTemplateName } | undefined"Backend Template": { selected: ApiTemplateName }"Auth Settings": undefineddiff --git a/fastlane/metadata/android/en-US/changelogs/51.txt b/fastlane/metadata/android/en-US/changelogs/51.txtindex 42b587f6..f169146d 100644--- a/fastlane/metadata/android/en-US/changelogs/51.txt+++ b/fastlane/metadata/android/en-US/changelogs/51.txt@@ -4,3 +4,4 @@- A tracking profile's sync interval takes effect as soon as the profile switches- Tracking that cannot restart after a reboot because location services are off shows a tap-to-resume notification and resumes by itself within about 10 minutes of turning them on- Elevation and a point's accuracy and altitude follow the Units setting, and distances and speeds use your device's decimal separator+- A Language setting under Appearance picks the app language; translations can now be contributed