Colota - Android GPS Location tracker
refactor(i18n): move Tracking & sync into the catalog (#899)
Max Dietrich0f7a58e3deac
diff --git a/apps/mobile/src/components/features/settings/SyncIntervalPicker.tsx b/apps/mobile/src/components/features/settings/SyncIntervalPicker.tsxindex 86bb5415..118c9899 100644--- a/apps/mobile/src/components/features/settings/SyncIntervalPicker.tsx+++ b/apps/mobile/src/components/features/settings/SyncIntervalPicker.tsx@@ -8,18 +8,12 @@ import { View, Text, StyleSheet } from "react-native"import { useTheme } from "../../../hooks/useTheme"import { useTimeout } from "../../../hooks/useTimeout"import { fontSizes, fonts, lineHeights } from "../../../styles/typography"-import {- SAVE_SUCCESS_DISPLAY_MS,- SYNC_INTERVAL_LABELS,- SYNC_INTERVAL_PRESETS,- SYNC_INTERVAL_SUBS,- size,- space-} from "../../../constants"+import { SAVE_SUCCESS_DISPLAY_MS, SYNC_INTERVAL_PRESETS, SYNC_INTERVAL_SUB_KEYS, size, space } from "../../../constants"import { NumericInput } from "../../ui/NumericInput"import { RadioRow } from "../../ui/RadioRow"-import { formatDuration } from "../../../utils/dashboardState"+import { formatDuration, syncIntervalLabel } from "../../../utils/dashboardState"import { parseWholeNumber, wholeNumberError } from "../../../utils/settingsValidation"+import { useTranslation } from "../../../i18n/useTranslation"type SyncIntervalPickerProps = {/** A heading above the group; the settings screen titles the card instead and passes neither. */@@ -60,6 +54,7 @@ export function SyncIntervalPicker({testIDPrefix = "sync-interval"}: SyncIntervalPickerProps) {const { colors } = useTheme()+ const { t } = useTranslation()const [customOpen, setCustomOpen] = useState(false)const [input, setInput] = useState(value.toString())const [clampMessage, setClampMessage] = useState<string | undefined>()@@ -79,7 +74,7 @@ export function SyncIntervalPicker({notify(seconds)}- const fieldHint = `${min > 0 ? `At least ${min} s. ` : ""}Longer means fewer requests and a later server.`+ const fieldHint = min > 0 ? t("syncInterval.field.hintMin", { min }) : t("syncInterval.field.hint")return (<View>@@ -91,8 +86,8 @@ export function SyncIntervalPicker({<RadioRowkey={seconds}testID={`${testIDPrefix}-${seconds}`}- label={SYNC_INTERVAL_LABELS[seconds]}- sub={SYNC_INTERVAL_SUBS[seconds]}+ label={syncIntervalLabel(seconds)}+ sub={t(SYNC_INTERVAL_SUB_KEYS[seconds])}selected={!isCustom && value === seconds}onPress={() => {setCustomOpen(false)@@ -102,13 +97,13 @@ export function SyncIntervalPicker({))}<RadioRowtestID={`${testIDPrefix}-custom`}- label="Custom"+ label={t("common.custom")}sub={isCustom? value === 0- ? "Syncs each fix"- : `Syncs every ${formatDuration(value)}`- : "Set your own interval"+ ? t("syncInterval.custom.eachFix")+ : t("syncInterval.custom.every", { duration: formatDuration(value) })+ : t("syncInterval.custom.sub")}selected={isCustom}onPress={() => {@@ -120,7 +115,7 @@ export function SyncIntervalPicker({{isCustom && (<View style={styles.customField}><NumericInput- label="Sync interval"+ label={t("syncInterval.field")}value={input}onChange={(next) => {setInput(next)@@ -132,14 +127,14 @@ export function SyncIntervalPicker({const parsed = parseWholeNumber(input)if (parsed !== null && parsed >= min) returnsetInput(min.toString())- setClampMessage(`Set to ${min} s`)+ setClampMessage(t("validation.setTo", { value: min, unit: t("unit.s") }))clampTimer.set(() => setClampMessage(undefined), SAVE_SUCCESS_DISPLAY_MS)report(min, onClamp)}}- unit="s"+ unit={t("unit.s")}placeholder="300"hint={fieldHint}- error={wholeNumberError(input, min, "s")}+ error={wholeNumberError(input, min, t("unit.s"))}message={clampMessage}/></View>diff --git a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsxindex d4eba9aa..ad0ece50 100644--- a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx+++ b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx@@ -36,6 +36,8 @@ import { recordingClause } from "../../../utils/profileRow"import { parseWholeNumber, wholeNumberError } from "../../../utils/settingsValidation"import { isOverlandFormat } from "../../../utils/apiPayload"import NativeLocationService from "../../../services/NativeLocationService"+import { useTranslation } from "../../../i18n/useTranslation"+import type { TranslationKey } from "../../../i18n/options"interface SyncStrategySettingsProps {settings: Settings@@ -50,15 +52,11 @@ type NumericKey = "interval" | "distance" | "accuracyThreshold"const NUMERIC_MIN: Record<NumericKey, number> = { interval: 1, distance: 0, accuracyThreshold: 1 }-const SYNC_CONDITION_OPTIONS: { value: SyncCondition; label: string; sub: string }[] = [- {- value: "any",- label: "Any network",- sub: "Mobile data and Wi-Fi · syncs never wait, counts against your data plan"- },- { value: "wifi_any", label: "Wi-Fi or Ethernet", sub: "Unmetered networks only · fixes wait on mobile data" },- { value: "wifi_ssid", label: "Specific Wi-Fi network", sub: "One network by name · fixes wait elsewhere" },- { value: "vpn", label: "VPN", sub: "Only while a VPN is up · fixes wait otherwise" }+const SYNC_CONDITION_OPTIONS: { value: SyncCondition; labelKey: TranslationKey; subKey: TranslationKey }[] = [+ { value: "any", labelKey: "trackingSync.condition.any", subKey: "trackingSync.condition.any.sub" },+ { value: "wifi_any", labelKey: "trackingSync.condition.wifiAny", subKey: "trackingSync.condition.wifiAny.sub" },+ { value: "wifi_ssid", labelKey: "trackingSync.condition.wifiSsid", subKey: "trackingSync.condition.wifiSsid.sub" },+ { value: "vpn", labelKey: "trackingSync.condition.vpn", subKey: "trackingSync.condition.vpn.sub" }]const lowerFirst = (text: string) => text.charAt(0).toLowerCase() + text.slice(1)@@ -71,6 +69,7 @@ export function SyncStrategySettings({activeProfile = null}: SyncStrategySettingsProps) {const { colors } = useTheme()+ const { t } = useTranslation()const unit = shortDistanceUnit()const [intervalInput, setIntervalInput] = useState(settings.interval.toString())const [distanceInput, setDistanceInput] = useState(metersToInput(settings.distance ?? 0).toString())@@ -137,7 +136,7 @@ export function SyncStrategySettings({const num = parseWholeNumber(inputOf(key))if (num !== null && num >= min) returnsetInput(key, min.toString())- noteClamp(key, `Set to ${min} ${key === "interval" ? "s" : unit}`)+ noteClamp(key, t("validation.setTo", { value: min, unit: key === "interval" ? t("unit.s") : unit }))const next = { ...settings, [key]: toStored(key, min) }onSettingsChange(next)onImmediateSave(next)@@ -193,7 +192,7 @@ export function SyncStrategySettings({if (num !== null && num >= OVERLAND_BATCH_MIN && num <= OVERLAND_BATCH_MAX) returnconst clamped = num === null || num < OVERLAND_BATCH_MIN ? OVERLAND_BATCH_MIN : OVERLAND_BATCH_MAXsetOverlandBatchSizeInput(clamped.toString())- noteClamp("batch", `Set to ${clamped} points`)+ noteClamp("batch", t("trackingSync.batch.setTo", { count: clamped, n: clamped }))const next = { ...settings, overlandBatchSize: clamped }onSettingsChange(next)onImmediateSave(next)@@ -202,39 +201,38 @@ export function SyncStrategySettings({const batchError = (() => {if (overlandBatchSizeInput === "") return undefinedconst num = parseWholeNumber(overlandBatchSizeInput)- if (num === null) return "A whole number"- if (num < OVERLAND_BATCH_MIN || num > OVERLAND_BATCH_MAX) return `${OVERLAND_BATCH_MIN} to ${OVERLAND_BATCH_MAX}`+ if (num === null) return t("validation.wholeNumber")+ if (num < OVERLAND_BATCH_MIN || num > OVERLAND_BATCH_MAX)+ return t("trackingSync.batch.range", { min: OVERLAND_BATCH_MIN, max: OVERLAND_BATCH_MAX })return undefined})()const presetSub = (preset: SelectablePreset) => {const config = TRACKING_PRESETS[preset]- return `${trackingSummary(config.interval, config.distance, config.syncInterval, settings.isOfflineMode)} · ${config.cost}`+ return `${trackingSummary(config.interval, config.distance, config.syncInterval, settings.isOfflineMode)} · ${t(config.costKey)}`}const thresholdShown = `${metersToInput(settings.accuracyThreshold)} ${unit}`const filterHint = settings.filterInaccurateLocations- ? `Drops fixes the chip rates worse than ${thresholdShown}. Stricter leaves gaps indoors.`- : `Every fix is kept. When on, fixes worse than ${thresholdShown} are dropped.`+ ? t("trackingSync.filter.on", { threshold: thresholdShown })+ : t("trackingSync.filter.off", { threshold: thresholdShown })const ssidTyped = settings.syncSsidconst offerCurrentSsid = currentSsid !== "" && currentSsid.toLowerCase() !== ssidTyped.toLowerCase()return (<View>- <Text style={[styles.intro, { color: colors.textSecondary }]}>- How often a fix is recorded and when it syncs. Changes apply at once and restart tracking.- </Text>+ <Text style={[styles.intro, { color: colors.textSecondary }]}>{t("trackingSync.intro")}</Text>- <SectionTitle>Recording</SectionTitle>+ <SectionTitle>{t("trackingSync.section.recording")}</SectionTitle><Card rows>{activeProfile && (<><StateLineicon={UserRoundPen}iconColor={colors.textSecondary}- label={`${activeProfile.name} is active`}- caption={`In force: ${lowerFirst(recordingClause(activeProfile))}`}+ label={t("trackingSync.profileActive", { name: activeProfile.name })}+ caption={t("trackingSync.inForce", { clause: lowerFirst(recordingClause(activeProfile)) })}testID="profile-override-recording"/><Divider tight />@@ -245,7 +243,7 @@ export function SyncStrategySettings({<RadioRowkey={preset}testID={`preset-${preset}`}- label={TRACKING_PRESETS[preset].label}+ label={t(TRACKING_PRESETS[preset].labelKey)}sub={presetSub(preset)}selected={settings.syncPreset === preset}onPress={() => handlePresetSelect(preset)}@@ -253,11 +251,11 @@ export function SyncStrategySettings({))}<RadioRowtestID="preset-custom"- label="Custom"+ label={t("common.custom")}sub={isCustomPreset? trackingSummary(settings.interval, settings.distance, settings.syncInterval, settings.isOfflineMode)- : "Your own interval and movement threshold"+ : t("trackingSync.custom.sub")}selected={isCustomPreset}onPress={handleCustomSelect}@@ -266,25 +264,25 @@ export function SyncStrategySettings({{isCustomPreset && (<View style={styles.reveal}><NumericInput- label="Interval"+ label={t("trackingSync.interval")}value={intervalInput}onChange={(val) => handleNumericChange("interval", val)}onBlur={() => handleNumericBlur("interval")}- unit="s"+ unit={t("unit.s")}placeholder="30"- hint="At least 1 s. Shorter keeps the GPS awake more of the time and records more points."- error={wholeNumberError(intervalInput, NUMERIC_MIN.interval, "s")}+ hint={t("trackingSync.interval.hint")}+ error={wholeNumberError(intervalInput, NUMERIC_MIN.interval, t("unit.s"))}message={clampNote("interval")}/><NumericInput- label="Movement threshold"+ label={t("trackingSync.distance")}value={distanceInput}onChange={(val) => handleNumericChange("distance", val)}onBlur={() => handleNumericBlur("distance")}unit={unit}placeholder="2"- hint="Skips a fix closer than this to the last one. 0 keeps every fix. Saves storage, not battery."+ hint={t("trackingSync.distance.hint")}error={wholeNumberError(distanceInput, NUMERIC_MIN.distance, unit)}message={clampNote("distance")}/>@@ -295,15 +293,15 @@ export function SyncStrategySettings({{!settings.isOfflineMode && (<>- <SectionTitle style={styles.groupTop}>Sync interval</SectionTitle>+ <SectionTitle style={styles.groupTop}>{t("trackingSync.section.syncInterval")}</SectionTitle><Card rows>{activeProfile && (<><StateLineicon={UserRoundPen}iconColor={colors.textSecondary}- label={`${activeProfile.name} is active`}- caption={`In force: ${syncSummary(activeProfile.syncInterval)}`}+ label={t("trackingSync.profileActive", { name: activeProfile.name })}+ caption={t("trackingSync.inForce", { clause: syncSummary(activeProfile.syncInterval) })}testID="profile-override-sync"/><Divider tight />@@ -322,13 +320,13 @@ export function SyncStrategySettings({<Divider tight /><View style={styles.batch}><NumericInput- label="Batch size"+ label={t("trackingSync.batch")}value={overlandBatchSizeInput}onChange={handleBatchChange}onBlur={handleBatchBlur}- unit="points"+ unit={t("unit.points")}placeholder="50"- hint={`${OVERLAND_BATCH_MIN} to ${OVERLAND_BATCH_MAX} points per request. Larger means fewer requests and bigger payloads.`}+ hint={t("trackingSync.batch.hint", { min: OVERLAND_BATCH_MIN, max: OVERLAND_BATCH_MAX })}error={batchError}message={clampNote("batch")}/>@@ -337,15 +335,15 @@ export function SyncStrategySettings({)}</Card>- <SectionTitle style={styles.groupTop}>Sync only on</SectionTitle>+ <SectionTitle style={styles.groupTop}>{t("trackingSync.section.syncOn")}</SectionTitle><Card rows><View accessibilityRole="radiogroup" style={styles.group}>- {SYNC_CONDITION_OPTIONS.map(({ value, label, sub }) => (+ {SYNC_CONDITION_OPTIONS.map(({ value, labelKey, subKey }) => (<React.Fragment key={value}><RadioRowtestID={`sync-condition-${value}`}- label={label}- sub={sub}+ label={t(labelKey)}+ sub={t(subKey)}selected={settings.syncCondition === value}onPress={() => {const next = { ...settings, syncCondition: value }@@ -357,7 +355,7 @@ export function SyncStrategySettings({{value === "wifi_ssid" && settings.syncCondition === "wifi_ssid" && (<View style={[styles.reveal, offerCurrentSsid ? styles.revealButtonTail : styles.revealTail]}><TextField- label="Network name"+ label={t("trackingSync.ssid")}testID="sync-ssid-input"monovalue={ssidTyped}@@ -366,15 +364,15 @@ export function SyncStrategySettings({onSettingsChange(next)onDebouncedSave(next)}}- placeholder="As shown in Wi-Fi settings"+ placeholder={t("trackingSync.ssid.placeholder")}autoCapitalize="none"autoCorrect={false}- error={ssidTyped.trim() === "" ? "Nothing syncs until a network is named" : undefined}+ error={ssidTyped.trim() === "" ? t("trackingSync.ssid.empty") : undefined}/>{offerCurrentSsid && (<Buttonvariant="secondary"- title={`Use ${currentSsid}`}+ title={t("trackingSync.ssid.use", { ssid: currentSsid })}testID="sync-ssid-use"onPress={() => {const next = { ...settings, syncSsid: currentSsid }@@ -392,11 +390,11 @@ export function SyncStrategySettings({</>)}- <SectionTitle style={styles.groupTop}>Accuracy filter</SectionTitle>+ <SectionTitle style={styles.groupTop}>{t("trackingSync.section.accuracy")}</SectionTitle><Card rows>- <SettingRow label="Filter inaccurate locations" hint={filterHint}>+ <SettingRow label={t("trackingSync.filter")} hint={filterHint}><Toggle- accessibilityLabel="Filter inaccurate locations"+ accessibilityLabel={t("trackingSync.filter")}value={settings.filterInaccurateLocations}onValueChange={(value) => {const next = { ...settings, filterInaccurateLocations: value }@@ -409,13 +407,13 @@ export function SyncStrategySettings({{settings.filterInaccurateLocations && (<View style={styles.filterField}><NumericInput- label="Accuracy threshold"+ label={t("trackingSync.threshold")}value={accuracyThresholdInput}onChange={(val) => handleNumericChange("accuracyThreshold", val)}onBlur={() => handleNumericBlur("accuracyThreshold")}unit={unit}placeholder="50"- hint={`At least 1 ${unit}. The chip's own estimate, often optimistic; lower drops more fixes.`}+ hint={t("trackingSync.threshold.hint", { unit })}error={wholeNumberError(accuracyThresholdInput, NUMERIC_MIN.accuracyThreshold, unit)}message={clampNote("accuracyThreshold")}/>diff --git a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsxindex 218c4c16..3673191b 100644--- a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx+++ b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx@@ -543,5 +543,14 @@ describe("SyncStrategySettings", () => {)expect(getByText("Set to 500 points")).toBeTruthy()})++ it("words the clamp to the minimum in the singular, since the floor of 1 is the note most users see", () => {+ const { getByDisplayValue, getByText } = renderComponent({ ...overland, overlandBatchSize: 50 })++ fireEvent.changeText(getByDisplayValue("50"), "0")+ fireEvent(getByDisplayValue("0"), "blur")++ expect(getByText("Set to 1 point")).toBeTruthy()+ })})})diff --git a/apps/mobile/src/constants/index.ts b/apps/mobile/src/constants/index.tsindex ffd98bc4..a80fd2aa 100644--- a/apps/mobile/src/constants/index.ts+++ b/apps/mobile/src/constants/index.ts@@ -4,6 +4,7 @@*/import type { ProfileConditionType } from "../types/global"+import type { TranslationKey } from "../i18n/options"import { Zap, Car, ArrowUp, ArrowDown, Pause } from "lucide-react-native"// Timing@@ -141,18 +142,11 @@ export function defaultProfileDelays(conditionType: ProfileConditionType): {// Sync Intervalexport const SYNC_INTERVAL_PRESETS: readonly number[] = [0, 60, 300, 900]-export const SYNC_INTERVAL_LABELS: Record<number, string> = {- 0: "Instant",- 60: "1 min",- 300: "5 min",- 900: "15 min"-}--export const SYNC_INTERVAL_SUBS: Record<number, string> = {- 0: "Each fix is its own request · radio never idles",- 60: "One request a minute · fixes wait in between",- 300: "One request every 5 min · fewer wake-ups",- 900: "One request every 15 min · the server hears you up to 15 min late"+export const SYNC_INTERVAL_SUB_KEYS: Record<number, TranslationKey> = {+ 0: "syncInterval.sub.0",+ 60: "syncInterval.sub.60",+ 300: "syncInterval.sub.300",+ 900: "syncInterval.sub.900"}// Overland batch envelope (Dawarich + batch mode, Overland template)diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.jsonindex 2b21f215..2fa33605 100644--- a/apps/mobile/src/i18n/locales/en.json+++ b/apps/mobile/src/i18n/locales/en.json@@ -76,5 +76,71 @@"settings.logging.off": "File logging off","settings.data.none": "No locations recorded","settings.data.locations_one": "{{n}} location · {{size}}",- "settings.data.locations_other": "{{n}} locations · {{size}}"+ "settings.data.locations_other": "{{n}} locations · {{size}}",+ "common.custom": "Custom",+ "unit.s": "s",+ "unit.min": "min",+ "unit.h": "h",+ "unit.points": "points",+ "validation.wholeNumber": "A whole number",+ "validation.atLeast": "At least {{min}} {{unit}}",+ "validation.setTo": "Set to {{value}} {{unit}}",+ "tracking.every": "Every {{duration}}",+ "tracking.recording.anyMovement": "Every {{duration}}, any movement",+ "tracking.recording.after": "Every {{duration}} after {{distance}}",+ "tracking.sync.eachFix": "syncs each fix",+ "tracking.sync.every": "syncs every {{duration}}",+ "tracking.interval.instantSync": "Instant sync",+ "tracking.interval.sync": "Sync {{duration}}",+ "tracking.preset.instant": "Instant",+ "tracking.preset.instant.cost": "most battery, finest track",+ "tracking.preset.balanced": "Balanced",+ "tracking.preset.balanced.cost": "moderate battery, fewer wake-ups",+ "tracking.preset.powersaver": "Power saver",+ "tracking.preset.powersaver.cost": "least battery, coarser track",+ "syncInterval.instant": "Instant",+ "syncInterval.sub.0": "Each fix is its own request · radio never idles",+ "syncInterval.sub.60": "One request a minute · fixes wait in between",+ "syncInterval.sub.300": "One request every 5 min · fewer wake-ups",+ "syncInterval.sub.900": "One request every 15 min · the server hears you up to 15 min late",+ "syncInterval.custom.eachFix": "Syncs each fix",+ "syncInterval.custom.every": "Syncs every {{duration}}",+ "syncInterval.custom.sub": "Set your own interval",+ "syncInterval.field": "Sync interval",+ "syncInterval.field.hint": "Longer means fewer requests and a later server.",+ "syncInterval.field.hintMin": "At least {{min}} s. Longer means fewer requests and a later server.",+ "trackingSync.intro": "How often a fix is recorded and when it syncs. Changes apply at once and restart tracking.",+ "trackingSync.section.recording": "Recording",+ "trackingSync.section.syncInterval": "Sync interval",+ "trackingSync.section.syncOn": "Sync only on",+ "trackingSync.section.accuracy": "Accuracy filter",+ "trackingSync.profileActive": "{{name}} is active",+ "trackingSync.inForce": "In force: {{clause}}",+ "trackingSync.custom.sub": "Your own interval and movement threshold",+ "trackingSync.interval": "Interval",+ "trackingSync.interval.hint": "At least 1 s. Shorter keeps the GPS awake more of the time and records more points.",+ "trackingSync.distance": "Movement threshold",+ "trackingSync.distance.hint": "Skips a fix closer than this to the last one. 0 keeps every fix. Saves storage, not battery.",+ "trackingSync.batch": "Batch size",+ "trackingSync.batch.hint": "{{min}} to {{max}} points per request. Larger means fewer requests and bigger payloads.",+ "trackingSync.batch.range": "{{min}} to {{max}}",+ "trackingSync.batch.setTo_one": "Set to {{n}} point",+ "trackingSync.batch.setTo_other": "Set to {{n}} points",+ "trackingSync.condition.any": "Any network",+ "trackingSync.condition.any.sub": "Mobile data and Wi-Fi · syncs never wait, counts against your data plan",+ "trackingSync.condition.wifiAny": "Wi-Fi or Ethernet",+ "trackingSync.condition.wifiAny.sub": "Unmetered networks only · fixes wait on mobile data",+ "trackingSync.condition.wifiSsid": "Specific Wi-Fi network",+ "trackingSync.condition.wifiSsid.sub": "One network by name · fixes wait elsewhere",+ "trackingSync.condition.vpn": "VPN",+ "trackingSync.condition.vpn.sub": "Only while a VPN is up · fixes wait otherwise",+ "trackingSync.ssid": "Network name",+ "trackingSync.ssid.placeholder": "As shown in Wi-Fi settings",+ "trackingSync.ssid.empty": "Nothing syncs until a network is named",+ "trackingSync.ssid.use": "Use {{ssid}}",+ "trackingSync.filter": "Filter inaccurate locations",+ "trackingSync.filter.on": "Drops fixes the chip rates worse than {{threshold}}. Stricter leaves gaps indoors.",+ "trackingSync.filter.off": "Every fix is kept. When on, fixes worse than {{threshold}} are dropped.",+ "trackingSync.threshold": "Accuracy threshold",+ "trackingSync.threshold.hint": "At least 1 {{unit}}. The chip's own estimate, often optimistic; lower drops more fixes."}diff --git a/apps/mobile/src/screens/ProfileEditorScreen.tsx b/apps/mobile/src/screens/ProfileEditorScreen.tsxindex bdce1cb3..ae0c43c4 100644--- a/apps/mobile/src/screens/ProfileEditorScreen.tsx+++ b/apps/mobile/src/screens/ProfileEditorScreen.tsx@@ -28,13 +28,12 @@ import {import { Check, Trash2 } from "lucide-react-native"import { logger } from "../utils/logger"import { shortDistanceUnit, inputToMeters, metersToInput, getSpeedUnit, speedToInput, inputToSpeed } from "../utils/geo"-import { formatDuration } from "../utils/dashboardState"+import { formatDuration, syncIntervalLabel } from "../utils/dashboardState"import { conditionOf, profileSentence } from "../utils/profileRow"import { parseWholeNumber, wholeNumberError } from "../utils/settingsValidation"import {PROFILE_CONDITIONS,SAVE_SUCCESS_DISPLAY_MS,- SYNC_INTERVAL_LABELS,STATIONARY_MAX_INTERVAL_SECONDS,defaultProfileDelays,size,@@ -239,7 +238,7 @@ export function ProfileEditorScreen({ navigation, route }: RootScreenProps<"Prof}}, [profile, conditionLabel, isEditing, profileId, navigation])- const syncDefault = SYNC_INTERVAL_LABELS[settings.syncInterval] ?? formatDuration(settings.syncInterval)+ const syncDefault = syncIntervalLabel(settings.syncInterval)return (<Container>diff --git a/apps/mobile/src/screens/__tests__/ProfileEditorScreen.test.tsx b/apps/mobile/src/screens/__tests__/ProfileEditorScreen.test.tsxindex e61da8c7..af09223e 100644--- a/apps/mobile/src/screens/__tests__/ProfileEditorScreen.test.tsx+++ b/apps/mobile/src/screens/__tests__/ProfileEditorScreen.test.tsx@@ -57,7 +57,8 @@ jest.mock("../../contexts/TrackingProvider", () => ({jest.mock("../../components/features/settings/SyncIntervalPicker", () => {const R = require("react")const { View, Text, Pressable } = require("react-native")- const { SYNC_INTERVAL_PRESETS, SYNC_INTERVAL_LABELS } = require("../../constants")+ const { SYNC_INTERVAL_PRESETS } = require("../../constants")+ const { syncIntervalLabel } = require("../../utils/dashboardState")return {SyncIntervalPicker: ({ label, hint, value, onSelect }: any) =>R.createElement(@@ -74,7 +75,7 @@ jest.mock("../../components/features/settings/SyncIntervalPicker", () => {onPress: () => onSelect(seconds),accessibilityState: { checked: value === seconds }},- R.createElement(Text, null, SYNC_INTERVAL_LABELS[seconds])+ R.createElement(Text, null, syncIntervalLabel(seconds)))))diff --git a/apps/mobile/src/types/__tests__/defaults.test.ts b/apps/mobile/src/types/__tests__/defaults.test.tsindex 29d3ad2e..6a9ee93b 100644--- a/apps/mobile/src/types/__tests__/defaults.test.ts+++ b/apps/mobile/src/types/__tests__/defaults.test.ts@@ -1,4 +1,5 @@import { DEFAULT_SETTINGS, DEFAULT_FIELD_MAP, TRACKING_PRESETS, API_TEMPLATES, Settings } from "../global"+import { t } from "../../i18n/t"describe("DEFAULT_FIELD_MAP", () => {const requiredKeys = ["lat", "lon", "acc"]@@ -114,15 +115,15 @@ describe("TRACKING_PRESETS", () => {})it.each(presetNames)("%s has a label", (name) => {- expect(TRACKING_PRESETS[name].label).toBeTruthy()+ expect(t(TRACKING_PRESETS[name].labelKey)).toBeTruthy()})it.each(presetNames)("%s names its cost, which the row prints beside the numbers it prices", (name) => {- expect(TRACKING_PRESETS[name].cost).toMatch(/battery/)+ expect(t(TRACKING_PRESETS[name].costKey)).toMatch(/battery/)})it("labels read in sentence case, like every other row", () => {- expect(TRACKING_PRESETS.powersaver.label).toBe("Power saver")+ expect(t(TRACKING_PRESETS.powersaver.labelKey)).toBe("Power saver")})it("instant has shortest interval", () => {diff --git a/apps/mobile/src/types/global.ts b/apps/mobile/src/types/global.tsindex 92b6217c..d68eb9a2 100644--- a/apps/mobile/src/types/global.ts+++ b/apps/mobile/src/types/global.ts@@ -9,6 +9,7 @@import type { NativeStackNavigationProp } from "@react-navigation/native-stack"import type { RootStackParamList } from "./navigation"+import type { TranslationKey } from "../i18n/options"export interface ScreenProps {navigation: NativeStackNavigationProp<RootStackParamList>@@ -270,9 +271,9 @@ export interface TrackingPresetConfig {distance: numbersyncInterval: numberretryInterval: number- label: string+ labelKey: TranslationKey/** What the preset costs, read beside the numbers it prices. */- cost: string+ costKey: TranslationKey}export const TRACKING_PRESETS = {@@ -281,24 +282,24 @@ export const TRACKING_PRESETS = {distance: 0,syncInterval: 0,retryInterval: 30,- label: "Instant",- cost: "most battery, finest track"+ labelKey: "tracking.preset.instant",+ costKey: "tracking.preset.instant.cost"},balanced: {interval: 30,distance: 2,syncInterval: 300,retryInterval: 300,- label: "Balanced",- cost: "moderate battery, fewer wake-ups"+ labelKey: "tracking.preset.balanced",+ costKey: "tracking.preset.balanced.cost"},powersaver: {interval: 60,distance: 2,syncInterval: 900,retryInterval: 900,- label: "Power saver",- cost: "least battery, coarser track"+ labelKey: "tracking.preset.powersaver",+ costKey: "tracking.preset.powersaver.cost"}} as const satisfies Record<string, TrackingPresetConfig>diff --git a/apps/mobile/src/utils/__tests__/dashboardState.test.ts b/apps/mobile/src/utils/__tests__/dashboardState.test.tsindex db37ac34..3c47f2a6 100644--- a/apps/mobile/src/utils/__tests__/dashboardState.test.ts+++ b/apps/mobile/src/utils/__tests__/dashboardState.test.ts@@ -6,6 +6,7 @@ import {intervalText,pickBannerCondition,recordingSummary,+ syncIntervalLabel,syncSummary,trackingSummary,type StateInput@@ -255,6 +256,17 @@ describe("trackingSummary", () => {})})+describe("syncIntervalLabel", () => {+ it("names zero Instant, because a sync interval of 0 s means each fix goes out on its own", () => {+ expect(syncIntervalLabel(0)).toBe("Instant")+ })++ it("prints any other interval as its duration, so a custom value reads like the presets", () => {+ expect(syncIntervalLabel(60)).toBe("1 min")+ expect(syncIntervalLabel(90)).toBe("90 s")+ })+})+describe("formatLastFix", () => {it("has nothing to date when no fix was ever recorded", () => {expect(formatLastFix(null, NOW)).toBe("No fixes yet")diff --git a/apps/mobile/src/utils/dashboardState.ts b/apps/mobile/src/utils/dashboardState.tsindex 11af959e..6671a220 100644--- a/apps/mobile/src/utils/dashboardState.ts+++ b/apps/mobile/src/utils/dashboardState.ts@@ -4,6 +4,7 @@*/import { formatTime, formatWhen, metersToInput, shortDistanceUnit } from "./geo"+import { t } from "../i18n/t"export type BannerCondition = "permission" | "background" | "locationOff" | "battery"@@ -103,25 +104,35 @@ export function describeState(input: StateInput): StateDescription {}export function formatDuration(seconds: number): string {- if (seconds >= 3600 && seconds % 3600 === 0) return `${seconds / 3600} h`- if (seconds >= 60 && seconds % 60 === 0) return `${seconds / 60} min`- return `${seconds} s`+ if (seconds >= 3600 && seconds % 3600 === 0) return `${seconds / 3600} ${t("unit.h")}`+ if (seconds >= 60 && seconds % 60 === 0) return `${seconds / 60} ${t("unit.min")}`+ return `${seconds} ${t("unit.s")}`+}++/** "Instant" for 0, the duration otherwise: the sync-interval rows and the profile editor's default. */+export function syncIntervalLabel(seconds: number): string {+ return seconds === 0 ? t("syncInterval.instant") : formatDuration(seconds)}export function formatInterval(seconds: number): string {- return `Every ${formatDuration(seconds)}`+ return t("tracking.every", { duration: formatDuration(seconds) })}/** "Every 30 s after 2 m", or ", any movement" when no distance gates a fix. */export function recordingSummary(intervalSeconds: number, distanceMeters: number): string {- const gate =- distanceMeters === 0 ? ", any movement" : ` after ${metersToInput(distanceMeters)} ${shortDistanceUnit()}`- return `${formatInterval(intervalSeconds)}${gate}`+ const duration = formatDuration(intervalSeconds)+ if (distanceMeters === 0) return t("tracking.recording.anyMovement", { duration })+ return t("tracking.recording.after", {+ duration,+ distance: `${metersToInput(distanceMeters)} ${shortDistanceUnit()}`+ })}/** "syncs each fix" or "syncs every 5 min", lower case so a caption can carry it. */export function syncSummary(syncIntervalSeconds: number): string {- return syncIntervalSeconds === 0 ? "syncs each fix" : `syncs every ${formatDuration(syncIntervalSeconds)}`+ return syncIntervalSeconds === 0+ ? t("tracking.sync.eachFix")+ : t("tracking.sync.every", { duration: formatDuration(syncIntervalSeconds) })}/** The one line a preset row, the Custom row and the Settings row all print for a configuration. */@@ -136,7 +147,10 @@ export function trackingSummary(}export function intervalText(intervalSeconds: number, syncIntervalSeconds: number): string {- const sync = syncIntervalSeconds === 0 ? "Instant sync" : `Sync ${formatDuration(syncIntervalSeconds)}`+ const sync =+ syncIntervalSeconds === 0+ ? t("tracking.interval.instantSync")+ : t("tracking.interval.sync", { duration: formatDuration(syncIntervalSeconds) })return `${formatInterval(intervalSeconds)} · ${sync}`}diff --git a/apps/mobile/src/utils/settingsValidation.ts b/apps/mobile/src/utils/settingsValidation.tsindex 8d9864aa..02a10644 100644--- a/apps/mobile/src/utils/settingsValidation.ts+++ b/apps/mobile/src/utils/settingsValidation.ts@@ -4,6 +4,7 @@*/import { API_TEMPLATES, type ApiTemplateName, type DawarichMode } from "../types/global"+import { t } from "../i18n/t"export const CUSTOM_ENDPOINT_EXAMPLE = "https://your-server.example/api"@@ -63,7 +64,7 @@ export function parseWholeNumber(text: string): number | null {export function wholeNumberError(text: string, min: number, unit: string): string | undefined {if (text === "") return undefinedconst value = parseWholeNumber(text)- if (value === null) return "A whole number"- if (value < min) return `At least ${min} ${unit}`+ if (value === null) return t("validation.wholeNumber")+ if (value < min) return t("validation.atLeast", { min, unit })return undefined}