Skip to content

Colota - Android GPS Location tracker

refactor(i18n): move Logging, About and setup links into the catalog (#915)

Max Dietrich737b343cc836
diff --git a/apps/mobile/src/components/ui/ErrorBoundary.tsx b/apps/mobile/src/components/ui/ErrorBoundary.tsx
index b31f3e33..bc7e5ca0 100644
--- a/apps/mobile/src/components/ui/ErrorBoundary.tsx
+++ b/apps/mobile/src/components/ui/ErrorBoundary.tsx
@@ -11,6 +11,7 @@ import { fontSizes, type } from "../../styles/typography"
import { space } from "../../constants"
import { Button } from "./Button"
+import { t } from "../../i18n/t"
interface ErrorBoundaryInternalProps {
children: React.ReactNode
@@ -46,11 +47,11 @@ class ErrorBoundaryInternal extends Component<ErrorBoundaryInternalProps, ErrorB
if (this.state.hasError) {
return (
<View style={[styles.errorContainer, { backgroundColor: colors.background }]}>
- <Text style={[styles.errorTitle, { color: colors.text }]}>Something went wrong</Text>
+ <Text style={[styles.errorTitle, { color: colors.text }]}>{t("error.title")}</Text>
<Text style={[styles.errorMessage, { color: colors.textSecondary }]}>
- {this.state.error?.message || "An unexpected error occurred"}
+ {this.state.error?.message || t("error.unexpected")}
</Text>
- <Button title="Try again" onPress={this.handleReset} />
+ <Button title={t("error.retry")} onPress={this.handleReset} />
</View>
)
}
diff --git a/apps/mobile/src/components/ui/FloatingSaveIndicator.tsx b/apps/mobile/src/components/ui/FloatingSaveIndicator.tsx
index 4af4bdf6..0fb7a1c9 100644
--- a/apps/mobile/src/components/ui/FloatingSaveIndicator.tsx
+++ b/apps/mobile/src/components/ui/FloatingSaveIndicator.tsx
@@ -11,6 +11,7 @@ import { SpinningLoader } from "./SpinningLoader"
import { useTheme } from "../../hooks/useTheme"
import { fontSizes, fonts } from "../../styles/typography"
import { size, space, elevation } from "../../constants"
+import { useTranslation } from "../../i18n/useTranslation"
interface Props {
saving: boolean
@@ -41,7 +42,8 @@ export const FloatingSaveIndicator: React.FC<Props> = ({ saving, message, isErro
}
}, [visible, translateY, opacity])
- const displayText = hasMessage ? message : "Saving..."
+ const { t } = useTranslation()
+ const displayText = hasMessage ? message : t("autoSave.saving")
return (
<Animated.View
diff --git a/apps/mobile/src/hooks/useAutoSave.ts b/apps/mobile/src/hooks/useAutoSave.ts
index e7dec732..97255222 100644
--- a/apps/mobile/src/hooks/useAutoSave.ts
+++ b/apps/mobile/src/hooks/useAutoSave.ts
@@ -7,6 +7,7 @@ import { useState, useCallback } from "react"
import { useTimeout } from "./useTimeout"
import { AUTOSAVE_DEBOUNCE_MS, SAVE_SUCCESS_DISPLAY_MS } from "../constants"
import { logger } from "../utils/logger"
+import { t } from "../i18n/t"
/**
* The debounced auto-save behind the settings screens.
@@ -35,10 +36,10 @@ export function useAutoSave() {
const runRestart = useCallback(
async (restartFn: () => Promise<boolean>) => {
try {
- if (await restartFn()) announce("Tracking restarted", false)
+ if (await restartFn()) announce(t("autoSave.restarted"), false)
} catch (err) {
logger.error("[useAutoSave] Restart failed:", err)
- announce("Could not restart tracking", true)
+ announce(t("autoSave.restartFailed"), true)
} finally {
setSaving(false)
}
@@ -59,7 +60,7 @@ export function useAutoSave() {
} catch (err) {
setSaving(false)
logger.error("[useAutoSave] Save failed:", err)
- announce("Could not save", true)
+ announce(t("autoSave.saveFailed"), true)
return
}
// Restart immediately: the input was already debounced by saveTimeout.
@@ -86,7 +87,7 @@ export function useAutoSave() {
.catch((err) => {
setSaving(false)
logger.error("[useAutoSave] Save failed:", err)
- announce("Could not save", true)
+ announce(t("autoSave.saveFailed"), true)
})
},
[saveTimeout, restartTimeout, runRestart, announce]
diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.json
index 9053fda3..07d208a8 100644
--- a/apps/mobile/src/i18n/locales/en.json
+++ b/apps/mobile/src/i18n/locales/en.json
@@ -1063,5 +1063,161 @@
"offline.deleteName": "Delete {{name}}",
"offline.empty.title": "No saved areas yet",
"offline.empty.hint": "Download map tiles to browse your tracks offline while hiking or camping",
- "backup.pickedFallback": "the file you chose"
+ "backup.pickedFallback": "the file you chose",
+ "log.result.file_one": "{{n}} line from the log file",
+ "log.result.file_other": "{{n}} lines from the log file",
+ "log.result.system_one": "{{n}} line from the system log",
+ "log.result.system_other": "{{n}} lines from the system log",
+ "log.resultOf.file_one": "{{shown}} of {{n}} line from the log file",
+ "log.resultOf.file_other": "{{shown}} of {{n}} lines from the log file",
+ "log.resultOf.system_one": "{{shown}} of {{n}} line from the system log",
+ "log.resultOf.system_other": "{{shown}} of {{n}} lines from the system log",
+ "log.contents": "The file names your geofences, your tracking profiles and your server host. Colota writes no coordinates into it, but a rejected upload can carry your server's reply. Read it before you attach it.",
+ "log.captureHint": "Keeps writing until you switch it off, restarts included.",
+ "log.recording": "Recording",
+ "log.notRecording": "Not recording",
+ "log.nothingWritten": "Nothing written yet",
+ "log.since": "{{size}} since {{time}}",
+ "log.written": "{{size}} written",
+ "log.kept": "{{size}} kept from an earlier capture",
+ "log.noFile": "No log file on this device",
+ "log.preview.file": "The log file's most recent lines",
+ "log.preview.system": "The system log's last few minutes",
+ "log.next.on": "Nothing written yet. Leave this on while you reproduce the problem, then come back and save the file.",
+ "log.next.off": "Switch on Record a log file, reproduce the problem, then come back and save the file.",
+ "log.delete.sub": "Removes {{size}}.",
+ "log.delete.confirm": "Deletes {{size}} of recorded log. Anything you have not saved is gone for good.",
+ "log.floor.all": "All {{n}}",
+ "log.floor.info": "Info {{n}}",
+ "log.floor.warn": "Warnings {{n}}",
+ "log.floor.error": "Errors {{n}}",
+ "log.level.DEBUG": "Debug",
+ "log.level.INFO": "Info",
+ "log.level.WARN": "Warn",
+ "log.level.ERROR": "Error",
+ "logging.changeFailed.title": "Could not change logging",
+ "logging.changeFailed.message": "The setting was not saved. Try again.",
+ "logging.save.title": "Save the log file?",
+ "logging.save.confirm": "Choose folder",
+ "logging.saved.title": "Log saved",
+ "logging.saved.message": "The file is in the folder you chose. Attach it to your report.",
+ "logging.nothing.title": "Nothing to save",
+ "logging.nothing.message": "There are no recorded log entries yet.",
+ "logging.saveFailed.title": "Could not save the log",
+ "logging.saveFailed.message": "Pick a different folder.",
+ "logging.delete.title": "Delete the log file?",
+ "logging.deleteFailed.title": "Could not delete the log",
+ "logging.deleteFailed.message": "The file is still there. Try again.",
+ "logging.record": "Record a log file",
+ "logging.read": "Read the log",
+ "logging.section.file": "The log file",
+ "logging.saveRow": "Save log file",
+ "logging.saving": "Saving…",
+ "logging.saveRow.sub": "To a folder you pick",
+ "logging.saveRow.hint": "Asks you to confirm, then saves the file",
+ "logging.deleteRow": "Delete the log file",
+ "logging.deleting": "Deleting…",
+ "preview.refresh": "Refresh",
+ "preview.refresh.hint": "Reads the log again",
+ "preview.empty.title": "Nothing logged yet",
+ "preview.empty.hint": "Lines appear as the app records and syncs.",
+ "preview.search": "Search the log",
+ "preview.clear": "Clear search",
+ "preview.floor": "Lowest level shown",
+ "preview.noMatch.title": "No lines match",
+ "preview.noMatch.hint": "Try a different word, or lower the level.",
+ "preview.jump": "Jump to the newest line",
+ "setup.field.endpoint": "Endpoint",
+ "setup.field.interval": "Interval",
+ "setup.field.distanceThreshold": "Distance threshold",
+ "setup.field.syncInterval": "Sync interval",
+ "setup.field.retryInterval": "Retry interval",
+ "setup.field.accuracyThreshold": "Accuracy threshold",
+ "setup.field.filterInaccurate": "Filter inaccurate",
+ "setup.field.offlineMode": "Offline mode",
+ "setup.field.syncCondition": "Sync condition",
+ "setup.field.syncSSID": "Sync SSID",
+ "setup.field.apiTemplate": "API template",
+ "setup.field.httpMethod": "HTTP method",
+ "setup.field.dawarichMode": "Dawarich mode",
+ "setup.field.overlandBatchSize": "Overland batch size",
+ "setup.field.fieldMapping": "Field mapping",
+ "setup.field.customFields": "Custom fields",
+ "setup.field.authType": "Auth type",
+ "setup.field.username": "Username",
+ "setup.field.password": "Password",
+ "setup.field.bearerToken": "Bearer token",
+ "setup.field.customHeaders": "Custom headers",
+ "setup.fields_one": "{{n}} field",
+ "setup.fields_other": "{{n}} fields",
+ "setup.headers_one": "{{n}} header",
+ "setup.headers_other": "{{n}} headers",
+ "common.yes": "Yes",
+ "common.no": "No",
+ "setup.err.format": "Invalid configuration format",
+ "setup.err.publicHttp": "HTTP not allowed for public hosts",
+ "setup.err.host": "The server address must be a plain host, without user@ or a backslash",
+ "setup.err.rejected": "{{reason}}. Nothing from this link will be applied.",
+ "setup.err.none": "No valid settings found in configuration",
+ "setup.intro_one": "A setup link wants to apply {{n}} setting. Apply it only if you trust where it came from.",
+ "setup.intro_other": "A setup link wants to apply {{n}} settings. Apply it only if you trust where it came from.",
+ "setup.err.noData": "No configuration data in URL",
+ "setup.err.malformed": "Invalid configuration data. The URL may be malformed.",
+ "setup.applied.title": "Configuration Applied",
+ "setup.applied.message": "Settings have been updated successfully.",
+ "setup.applyFailed": "Failed to apply configuration. Please try again.",
+ "setup.sendsTo": "Sends locations to",
+ "setup.replacesServer": "Replaces your current server, {{host}}",
+ "setup.replace.both": "Replace zones and profiles with the same name",
+ "setup.replace.profiles": "Replace profiles with the same name",
+ "setup.replace.zones": "Replace zones with the same name",
+ "setup.replace.hint": "Off: imports are added as new entries",
+ "setup.invalid": "Invalid configuration",
+ "setup.goBack": "Go back",
+ "setup.section.tracking": "Tracking",
+ "setup.section.api": "API",
+ "setup.section.auth": "Authentication",
+ "setup.section.geofences": "Geofences",
+ "setup.section.profiles": "Tracking profiles",
+ "setup.apply": "Apply configuration",
+ "share.zones_one": "{{n}} zone",
+ "share.zones_other": "{{n}} zones",
+ "share.profiles_one": "{{n}} profile",
+ "share.profiles_other": "{{n}} profiles",
+ "share.failed": "Failed to share setup.",
+ "share.tracking": "Tracking",
+ "share.tracking.sub": "GPS interval, distance and accuracy filter",
+ "share.sync": "Sync",
+ "share.sync.sub": "Sync interval, conditions and offline mode",
+ "share.api": "API",
+ "share.api.sub": "Endpoint, template and field mapping",
+ "share.geofences": "Geofences",
+ "share.profilesRow": "Tracking profiles",
+ "share.noneSaved": "None saved",
+ "share.credentials": "Credentials",
+ "share.credentials.sub": "Authentication secrets - included only if checked",
+ "share.noneConfigured": "None configured",
+ "share.intro": "Choose what to bundle into a setup link, then share it. The recipient opens it to apply the same configuration.",
+ "share.include": "Include",
+ "share.cred.username": "username",
+ "share.cred.password": "password",
+ "share.cred.token": "bearer token",
+ "share.cred.headers": "custom headers",
+ "share.warning": "This link will contain your {{fields}} in plain text. Anyone who sees the link can read them - only share it over a trusted channel.",
+ "share.share": "Share",
+ "share.empty": "Select at least one category to share.",
+ "about.linkError": "Could not open the link.",
+ "about.legal": "Legal",
+ "about.privacy": "Privacy policy",
+ "about.license": "License",
+ "about.source": "Source code",
+ "autoSave.restarted": "Tracking restarted",
+ "autoSave.restartFailed": "Could not restart tracking",
+ "autoSave.saveFailed": "Could not save",
+ "autoSave.saving": "Saving...",
+ "error.title": "Something went wrong",
+ "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."
}
diff --git a/apps/mobile/src/screens/AboutScreen.tsx b/apps/mobile/src/screens/AboutScreen.tsx
index 07c471fc..0be808f8 100644
--- a/apps/mobile/src/screens/AboutScreen.tsx
+++ b/apps/mobile/src/screens/AboutScreen.tsx
@@ -17,15 +17,18 @@ import { fonts, fontSizes, lineHeights, type } from "../styles/typography"
import { PRIVACY_POLICY_URL, REPO_URL, space } from "../constants"
import icon from "../assets/icons/icon.png"
import type { ScreenProps } from "../types/global"
+import { useTranslation } from "../i18n/useTranslation"
+import { t as translate } from "../i18n/t"
export function AboutScreen({}: ScreenProps) {
const { colors } = useTheme()
+ const { t } = useTranslation()
const build = NativeLocationService.getBuildConfig()
const openURL = useCallback((url: string) => {
Linking.openURL(url).catch((err) => {
logger.error("[AboutScreen] Failed to open URL:", err)
- showAlert("Error", "Could not open the link.", "error")
+ showAlert(translate("common.error"), translate("about.linkError"), "error")
})
}, [])
@@ -43,12 +46,12 @@ export function AboutScreen({}: ScreenProps) {
</View>
<View style={styles.section}>
- <SectionTitle>Legal</SectionTitle>
+ <SectionTitle>{t("about.legal")}</SectionTitle>
<Card rows>
<ListItem
testID="nav-privacy-policy"
icon={FileText}
- label="Privacy policy"
+ label={t("about.privacy")}
sub="colota.app/privacy-policy"
trailingIcon={ExternalLink}
accessibilityRole="link"
@@ -58,7 +61,7 @@ export function AboutScreen({}: ScreenProps) {
<ListItem
testID="nav-license"
icon={ScrollText}
- label="License"
+ label={t("about.license")}
sub="GNU AGPLv3"
trailingIcon={ExternalLink}
accessibilityRole="link"
@@ -68,17 +71,14 @@ export function AboutScreen({}: ScreenProps) {
<ListItem
testID="nav-source-code"
icon={Code}
- label="Source code"
+ label={t("about.source")}
sub="github.com/dietrichmax/colota"
trailingIcon={ExternalLink}
accessibilityRole="link"
onPress={() => openURL(REPO_URL)}
/>
</Card>
- <Text style={[styles.copyright, { color: colors.textLight }]}>
- Copyright &copy; 2026 Max Dietrich and contributors. Colota is free software, with no warranty; the License
- row above has the terms.
- </Text>
+ <Text style={[styles.copyright, { color: colors.textLight }]}>{t("about.copyright")}</Text>
</View>
</ScrollView>
</Container>
diff --git a/apps/mobile/src/screens/LogPreviewScreen.tsx b/apps/mobile/src/screens/LogPreviewScreen.tsx
index 27a4d47f..026fcce3 100644
--- a/apps/mobile/src/screens/LogPreviewScreen.tsx
+++ b/apps/mobile/src/screens/LogPreviewScreen.tsx
@@ -41,6 +41,7 @@ import { fonts, fontSizes, lineHeights, type } from "../styles/typography"
import { HIT_SLOP_MD, LOG_FILTER_DEBOUNCE_MS, size, space, STATE_LAYER_ALPHA } from "../constants"
import { radius } from "@colota/shared"
import type { ScreenProps } from "../types/global"
+import { useTranslation } from "../i18n/useTranslation"
function levelColor(level: LogLevel, colors: ThemeColors): string {
switch (level) {
@@ -72,6 +73,7 @@ function LogLine({ entry }: { entry: MergedLogEntry }) {
export function LogPreviewScreen({ navigation }: ScreenProps) {
const { colors } = useTheme()
+ const { t } = useTranslation()
const debounce = useTimeout()
const [entries, setEntries] = useState<MergedLogEntry[]>([])
@@ -114,13 +116,13 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
() => (
<HeaderAction
icon={RefreshCw}
- label="Refresh"
- hint="Reads the log again"
+ label={t("preview.refresh")}
+ hint={t("preview.refresh.hint")}
onPress={load}
testID="refresh-log-btn"
/>
),
- [load]
+ [load, t]
)
useLayoutEffect(() => {
@@ -174,7 +176,7 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
if (entries.length === 0) {
return (
<Container>
- <EmptyState icon={FileSearch} title="Nothing logged yet" hint="Lines appear as the app records and syncs." />
+ <EmptyState icon={FileSearch} title={t("preview.empty.title")} hint={t("preview.empty.hint")} />
</Container>
)
}
@@ -186,8 +188,8 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
<Search size={size.icon.sm} color={colors.textLight} />
<TextInput
style={[styles.searchInput, { color: colors.text }]}
- accessibilityLabel="Search the log"
- placeholder="Search the log"
+ accessibilityLabel={t("preview.search")}
+ placeholder={t("preview.search")}
placeholderTextColor={colors.textLight}
value={text}
onChangeText={handleType}
@@ -198,7 +200,7 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
{text.length > 0 ? (
<Pressable
accessibilityRole="button"
- accessibilityLabel="Clear search"
+ accessibilityLabel={t("preview.clear")}
hitSlop={HIT_SLOP_MD}
android_ripple={{ color: colors.text + STATE_LAYER_ALPHA, borderless: true, radius: size.icon.md }}
onPress={clear}
@@ -209,7 +211,7 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
) : null}
</View>
- <ChipGroup accessibilityLabel="Lowest level shown" options={options} selected={floor} onSelect={setFloor} />
+ <ChipGroup accessibilityLabel={t("preview.floor")} options={options} selected={floor} onSelect={setFloor} />
<Text style={[styles.result, { color: colors.textSecondary }]} numberOfLines={1} testID="log-result-line">
{resultLine(shown.length, entries.length, fromFile)}
@@ -218,7 +220,7 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
<Divider tight />
{shown.length === 0 ? (
- <EmptyState icon={FileSearch} title="No lines match" hint="Try a different word, or lower the level." />
+ <EmptyState icon={FileSearch} title={t("preview.noMatch.title")} hint={t("preview.noMatch.hint")} />
) : (
<View style={styles.listArea}>
<FlatList
@@ -241,7 +243,7 @@ export function LogPreviewScreen({ navigation }: ScreenProps) {
<MapActionButton
anchored={false}
accessibilityRole="button"
- accessibilityLabel="Jump to the newest line"
+ accessibilityLabel={t("preview.jump")}
onPress={jumpToNewest}
testID="jump-to-newest-btn"
>
diff --git a/apps/mobile/src/screens/LoggingScreen.tsx b/apps/mobile/src/screens/LoggingScreen.tsx
index fda91f57..ff891f87 100644
--- a/apps/mobile/src/screens/LoggingScreen.tsx
+++ b/apps/mobile/src/screens/LoggingScreen.tsx
@@ -26,21 +26,25 @@ import { showAlert, showConfirm } from "../services/modalService"
import { logger } from "../utils/logger"
import { buildAppLog, buildExportHeader } from "../utils/logExport"
import {
- CAPTURE_HINT,
+ captureHint,
deleteConfirmMessage,
deleteSub,
describeCapture,
- LOG_CONTENTS_LINE,
+ logContentsLine,
nextStepLine,
previewRowSub
} from "../utils/logCapture"
import { LOG_SIZE_SETTLE_MS, space } from "../constants"
import type { ScreenProps } from "../types/global"
+import { useTranslation } from "../i18n/useTranslation"
+// Handlers use the non-hook t, so no callback list carries it.
+import { t as translate } from "../i18n/t"
type Busy = "save" | "delete" | null
export function LoggingScreen({ navigation }: ScreenProps) {
const { colors } = useTheme()
+ const { t } = useTranslation()
const settle = useTimeout()
const [enabled, setEnabled] = useState(false)
@@ -78,7 +82,7 @@ export function LoggingScreen({ navigation }: ScreenProps) {
} catch (err) {
logger.error("[LoggingScreen] setFileLoggingEnabled failed:", err)
setEnabled(!value)
- showAlert("Could not change logging", "The setting was not saved. Try again.", "error")
+ showAlert(translate("logging.changeFailed.title"), translate("logging.changeFailed.message"), "error")
return
}
// Native stamps the start and the first lines land off-thread, so read once it settles.
@@ -91,7 +95,13 @@ export function LoggingScreen({ navigation }: ScreenProps) {
const handleSave = useCallback(async () => {
if (busyRef.current) return
- if (!(await showConfirm({ title: "Save the log file?", message: LOG_CONTENTS_LINE, confirmText: "Choose folder" })))
+ if (
+ !(await showConfirm({
+ title: translate("logging.save.title"),
+ message: logContentsLine(),
+ confirmText: translate("logging.save.confirm")
+ }))
+ )
return
const treeUri = await NativeLocationService.pickExportDirectory()
@@ -111,13 +121,17 @@ export function LoggingScreen({ navigation }: ScreenProps) {
const header = buildExportHeader(buildConfig, deviceInfo, startedAt, Date.now())
const written = await NativeLocationService.exportFileLogToUri(treeUri, header, buildAppLog())
if (written) {
- showAlert("Log saved", "The file is in the folder you chose. Attach it to your report.", "success")
+ showAlert(translate("logging.saved.title"), translate("logging.saved.message"), "success")
} else {
- showAlert("Nothing to save", "There are no recorded log entries yet.", "info")
+ showAlert(translate("logging.nothing.title"), translate("logging.nothing.message"), "info")
}
} catch (err) {
logger.error("[LoggingScreen] save failed:", err)
- showAlert("Could not save the log", err instanceof Error ? err.message : "Pick a different folder.", "error")
+ showAlert(
+ translate("logging.saveFailed.title"),
+ err instanceof Error ? err.message : translate("logging.saveFailed.message"),
+ "error"
+ )
} finally {
busyRef.current = false
setBusy(null)
@@ -128,9 +142,9 @@ export function LoggingScreen({ navigation }: ScreenProps) {
if (busyRef.current) return
if (
!(await showConfirm({
- title: "Delete the log file?",
+ title: translate("logging.delete.title"),
message: deleteConfirmMessage(bytes),
- confirmText: "Delete",
+ confirmText: translate("common.delete"),
destructive: true
}))
) {
@@ -143,7 +157,7 @@ export function LoggingScreen({ navigation }: ScreenProps) {
await read()
} catch (err) {
logger.error("[LoggingScreen] clearFileLog failed:", err)
- showAlert("Could not delete the log", "The file is still there. Try again.", "error")
+ showAlert(translate("logging.deleteFailed.title"), translate("logging.deleteFailed.message"), "error")
} finally {
busyRef.current = false
setBusy(null)
@@ -167,9 +181,9 @@ export function LoggingScreen({ navigation }: ScreenProps) {
testID="capture-state"
/>
<Divider tight />
- <SettingRow label="Record a log file" hint={CAPTURE_HINT}>
+ <SettingRow label={t("logging.record")} hint={captureHint()}>
<Toggle
- accessibilityLabel="Record a log file"
+ accessibilityLabel={t("logging.record")}
value={enabled}
onValueChange={handleToggle}
testID="file-logging-toggle"
@@ -178,7 +192,7 @@ export function LoggingScreen({ navigation }: ScreenProps) {
<Divider tight />
<ListItem
icon={FileSearch}
- label="Read the log"
+ label={t("logging.read")}
sub={previewRowSub(enabled)}
subLines={2}
onPress={() => navigation.navigate("Log Preview")}
@@ -190,15 +204,15 @@ export function LoggingScreen({ navigation }: ScreenProps) {
{bytes > 0 ? (
<View style={styles.section}>
- <SectionTitle>The log file</SectionTitle>
+ <SectionTitle>{t("logging.section.file")}</SectionTitle>
<Card rows>
<ListItem
testID="save-log-row"
icon={FileText}
trailingIcon={busy === "save" ? SpinningLoader : Upload}
- label="Save log file"
- sub={busy === "save" ? "Saving…" : "To a folder you pick"}
- accessibilityHint="Asks you to confirm, then saves the file"
+ label={t("logging.saveRow")}
+ sub={busy === "save" ? t("logging.saving") : t("logging.saveRow.sub")}
+ accessibilityHint={t("logging.saveRow.hint")}
disabled={busy === "save" ? false : busy !== null}
onPress={handleSave}
/>
@@ -207,10 +221,10 @@ export function LoggingScreen({ navigation }: ScreenProps) {
testID="delete-log-row"
icon={FileX}
trailingIcon={busy === "delete" ? SpinningLoader : Trash2}
- label="Delete the log file"
- sub={busy === "delete" ? "Deleting…" : deleteSub(bytes, enabled)}
+ label={t("logging.deleteRow")}
+ sub={busy === "delete" ? t("logging.deleting") : deleteSub(bytes, enabled)}
subLines={2}
- accessibilityHint="Asks you to confirm, then deletes"
+ accessibilityHint={t("data.confirmThenDelete")}
disabled={busy === "delete" ? false : busy !== null}
onPress={handleDelete}
/>
diff --git a/apps/mobile/src/screens/SetupImportScreen.tsx b/apps/mobile/src/screens/SetupImportScreen.tsx
index 9ffd83d2..6dd2510f 100644
--- a/apps/mobile/src/screens/SetupImportScreen.tsx
+++ b/apps/mobile/src/screens/SetupImportScreen.tsx
@@ -34,9 +34,13 @@ import {
} from "../utils/setupConfig"
import { decodeConfig } from "../utils/setupLink"
import { space } from "../constants"
+import { useTranslation } from "../i18n/useTranslation"
+// Handlers and the parse memo use the non-hook t, so no dependency list carries it.
+import { t as translate } from "../i18n/t"
export function SetupImportScreen({ route, navigation }: any) {
const { colors } = useTheme()
+ const { t } = useTranslation()
const { settings: currentSettings, setSettings } = useTracking()
const [applying, setApplying] = useState(false)
const [replaceByName, setReplaceByName] = useState(false)
@@ -49,7 +53,7 @@ export function SetupImportScreen({ route, navigation }: any) {
valid: false,
config: { settings: {}, auth: null, geofences: [], profiles: [] },
entries: [],
- error: "No configuration data in URL"
+ error: translate("setup.err.noData")
} as ValidationResult
}
@@ -60,7 +64,7 @@ export function SetupImportScreen({ route, navigation }: any) {
valid: false,
config: { settings: {}, auth: null, geofences: [], profiles: [] },
entries: [],
- error: "Invalid configuration data. The URL may be malformed."
+ error: translate("setup.err.malformed")
} as ValidationResult
}
}, [route.params?.config])
@@ -131,11 +135,11 @@ export function SetupImportScreen({ route, navigation }: any) {
}
}
- showAlert("Configuration Applied", "Settings have been updated successfully.", "success")
+ showAlert(translate("setup.applied.title"), translate("setup.applied.message"), "success")
navigation.navigate("Dashboard")
} catch (e) {
logger.error("[SetupImport] Failed to apply config:", e)
- showAlert("Error", "Failed to apply configuration. Please try again.", "error")
+ showAlert(translate("common.error"), translate("setup.applyFailed"), "error")
} finally {
setApplying(false)
}
@@ -147,10 +151,12 @@ export function SetupImportScreen({ route, navigation }: any) {
const currentHost = current && current !== entry.value ? (setupEndpointHost(current) ?? current) : null
return (
<View style={styles.endpoint}>
- <Text style={[styles.endpointLabel, { color: colors.textSecondary }]}>Sends locations to</Text>
+ <Text style={[styles.endpointLabel, { color: colors.textSecondary }]}>{t("setup.sendsTo")}</Text>
<Text style={[styles.endpointHost, { color: colors.text }]}>{setupEndpointHost(entry.value)}</Text>
<Text style={[type.mono, { color: colors.textSecondary }]}>{entry.value}</Text>
- {currentHost && <FieldMessage variant="warning">Replaces your current server, {currentHost}</FieldMessage>}
+ {currentHost && (
+ <FieldMessage variant="warning">{t("setup.replacesServer", { host: currentHost })}</FieldMessage>
+ )}
</View>
)
}
@@ -162,9 +168,9 @@ export function SetupImportScreen({ route, navigation }: any) {
<SectionTitle>{title}</SectionTitle>
<Card>
{entries.map((entry, i) => (
- <React.Fragment key={entry.label}>
+ <React.Fragment key={`${entry.field}:${entry.label}`}>
{i > 0 && <Divider tight />}
- {entry.label === "Endpoint" ? renderEndpoint(entry) : <StatRow label={entry.label} value={entry.value} />}
+ {entry.field === "endpoint" ? renderEndpoint(entry) : <StatRow label={entry.label} value={entry.value} />}
</React.Fragment>
))}
</Card>
@@ -174,10 +180,10 @@ export function SetupImportScreen({ route, navigation }: any) {
const replaceLabel =
geofenceEntries.length > 0 && profileEntries.length > 0
- ? "Replace zones and profiles with the same name"
+ ? t("setup.replace.both")
: profileEntries.length > 0
- ? "Replace profiles with the same name"
- : "Replace zones with the same name"
+ ? t("setup.replace.profiles")
+ : t("setup.replace.zones")
const handleCancel = () => {
navigation.navigate("Dashboard")
@@ -188,8 +194,8 @@ export function SetupImportScreen({ route, navigation }: any) {
return (
<Container>
<ScrollView contentContainerStyle={styles.content}>
- <EmptyState icon={CircleAlert} title="Invalid configuration" hint={result.error} />
- <Button title="Go back" onPress={handleCancel} variant="primary" />
+ <EmptyState icon={CircleAlert} title={t("setup.invalid")} hint={result.error} />
+ <Button title={t("setup.goBack")} onPress={handleCancel} variant="primary" />
</ScrollView>
</Container>
)
@@ -200,20 +206,19 @@ export function SetupImportScreen({ route, navigation }: any) {
<Container>
<ScrollView contentContainerStyle={styles.content}>
<Text style={[styles.subtitle, { color: colors.textSecondary }]}>
- A setup link wants to apply {result.entries.length} setting{result.entries.length !== 1 ? "s" : ""}. Apply it
- only if you trust where it came from.
+ {t("setup.intro", { count: result.entries.length, n: result.entries.length })}
</Text>
- {renderSection("Tracking", trackingEntries)}
- {renderSection("API", apiEntries)}
- {renderSection("Authentication", authEntries)}
- {renderSection("Geofences", geofenceEntries)}
- {renderSection("Tracking profiles", profileEntries)}
+ {renderSection(t("setup.section.tracking"), trackingEntries)}
+ {renderSection(t("setup.section.api"), apiEntries)}
+ {renderSection(t("setup.section.auth"), authEntries)}
+ {renderSection(t("setup.section.geofences"), geofenceEntries)}
+ {renderSection(t("setup.section.profiles"), profileEntries)}
{(geofenceEntries.length > 0 || profileEntries.length > 0) && (
<View style={styles.section}>
<Card rows>
- <SettingRow label={replaceLabel} hint="Off: imports are added as new entries">
+ <SettingRow label={replaceLabel} hint={t("setup.replace.hint")}>
<Toggle
accessibilityLabel={replaceLabel}
testID="replace-imports-switch"
@@ -227,14 +232,14 @@ export function SetupImportScreen({ route, navigation }: any) {
<View style={styles.actions}>
<Button
- title="Apply configuration"
+ title={t("setup.apply")}
onPress={handleApply}
variant="primary"
icon={Check}
loading={applying}
disabled={applying}
/>
- <Button title="Cancel" onPress={handleCancel} variant="ghost" />
+ <Button title={t("common.cancel")} onPress={handleCancel} variant="ghost" />
</View>
</ScrollView>
</Container>
diff --git a/apps/mobile/src/screens/ShareSetupScreen.tsx b/apps/mobile/src/screens/ShareSetupScreen.tsx
index 33211c8f..c718d2ad 100644
--- a/apps/mobile/src/screens/ShareSetupScreen.tsx
+++ b/apps/mobile/src/screens/ShareSetupScreen.tsx
@@ -16,11 +16,15 @@ import { logger } from "../utils/logger"
import { buildSetupConfig, buildSetupLink, type SetupShareParts, type SetupShareSelection } from "../utils/setupLink"
import { DEFAULT_AUTH_CONFIG, type AuthConfig, type Geofence, type TrackingProfile } from "../types/global"
import { size, space } from "../constants"
+import { useTranslation } from "../i18n/useTranslation"
+// Handlers and memos use the non-hook t, so no dependency list carries it.
+import { t as translate } from "../i18n/t"
type ShareCategory = keyof SetupShareSelection
export function ShareSetupScreen() {
const { colors } = useTheme()
+ const { t } = useTranslation()
const { settings } = useTracking()
const [auth, setAuth] = useState<AuthConfig>(DEFAULT_AUTH_CONFIG)
@@ -73,12 +77,12 @@ export function ShareSetupScreen() {
const credentialFields = useMemo(() => {
const fields: string[] = []
if (auth.authType === "basic") {
- if (auth.username) fields.push("username")
- if (auth.password) fields.push("password")
+ if (auth.username) fields.push(translate("share.cred.username"))
+ if (auth.password) fields.push(translate("share.cred.password"))
} else if (auth.authType === "bearer") {
- if (auth.bearerToken) fields.push("bearer token")
+ if (auth.bearerToken) fields.push(translate("share.cred.token"))
}
- if (Object.keys(auth.customHeaders).length > 0) fields.push("custom headers")
+ if (Object.keys(auth.customHeaders).length > 0) fields.push(translate("share.cred.headers"))
return fields
}, [auth])
@@ -92,30 +96,36 @@ export function ShareSetupScreen() {
await Share.share({ message: buildSetupLink(parts, selection) })
} catch (err) {
logger.error("[ShareSetup] Failed to share setup:", err)
- showAlert("Error", "Failed to share setup.", "error")
+ showAlert(translate("common.error"), translate("share.failed"), "error")
}
}, [parts, selection, isEmpty])
const rows: { key: ShareCategory; label: string; sub: string; disabled?: boolean }[] = [
- { key: "tracking", label: "Tracking", sub: "GPS interval, distance and accuracy filter" },
- { key: "sync", label: "Sync", sub: "Sync interval, conditions and offline mode" },
- { key: "api", label: "API", sub: "Endpoint, template and field mapping" },
+ { key: "tracking", label: t("share.tracking"), sub: t("share.tracking.sub") },
+ { key: "sync", label: t("share.sync"), sub: t("share.sync.sub") },
+ { key: "api", label: t("share.api"), sub: t("share.api.sub") },
{
key: "geofences",
- label: "Geofences",
- sub: geofences.length > 0 ? `${geofences.length} zone${geofences.length === 1 ? "" : "s"}` : "None saved",
+ label: t("share.geofences"),
+ sub:
+ geofences.length > 0
+ ? t("share.zones", { count: geofences.length, n: geofences.length })
+ : t("share.noneSaved"),
disabled: geofences.length === 0
},
{
key: "profiles",
- label: "Tracking profiles",
- sub: profiles.length > 0 ? `${profiles.length} profile${profiles.length === 1 ? "" : "s"}` : "None saved",
+ label: t("share.profilesRow"),
+ sub:
+ profiles.length > 0
+ ? t("share.profiles", { count: profiles.length, n: profiles.length })
+ : t("share.noneSaved"),
disabled: profiles.length === 0
},
{
key: "credentials",
- label: "Credentials",
- sub: hasCredentials ? "Authentication secrets - included only if checked" : "None configured",
+ label: t("share.credentials"),
+ sub: hasCredentials ? t("share.credentials.sub") : t("share.noneConfigured"),
disabled: !hasCredentials
}
]
@@ -123,13 +133,10 @@ export function ShareSetupScreen() {
return (
<Container>
<ScrollView contentContainerStyle={styles.content}>
- <Text style={[styles.intro, { color: colors.textSecondary }]}>
- Choose what to bundle into a setup link, then share it. The recipient opens it to apply the same
- configuration.
- </Text>
+ <Text style={[styles.intro, { color: colors.textSecondary }]}>{t("share.intro")}</Text>
<View style={styles.section}>
- <SectionTitle>Include</SectionTitle>
+ <SectionTitle>{t("share.include")}</SectionTitle>
<Card rows>
{rows.map((row, i) => (
<React.Fragment key={row.key}>
@@ -154,8 +161,7 @@ export function ShareSetupScreen() {
<View style={styles.headerRow}>
<TriangleAlert size={size.icon.md} color={colors.error} />
<Text style={[styles.warningText, { color: colors.text }]}>
- This link will contain your {credentialFields.join(", ")} in plain text. Anyone who sees the link can
- read them - only share it over a trusted channel.
+ {t("share.warning", { fields: credentialFields.join(", ") })}
</Text>
</View>
</Card>
@@ -163,12 +169,8 @@ export function ShareSetupScreen() {
)}
<View style={styles.actions}>
- <Button title="Share" onPress={handleShare} variant="primary" icon={Share2} disabled={isEmpty} />
- {isEmpty && (
- <Text style={[styles.emptyHint, { color: colors.textSecondary }]}>
- Select at least one category to share.
- </Text>
- )}
+ <Button title={t("share.share")} onPress={handleShare} variant="primary" icon={Share2} disabled={isEmpty} />
+ {isEmpty && <Text style={[styles.emptyHint, { color: colors.textSecondary }]}>{t("share.empty")}</Text>}
</View>
</ScrollView>
</Container>
diff --git a/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx b/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
index 2db279f0..57f0633c 100644
--- a/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
@@ -179,7 +179,12 @@ describe("SetupImportScreen", () => {
it("parses custom headers", () => {
const { getByText } = renderScreen(encode({ customHeaders: { "X-Api-Key": "secret" } }))
- expect(getByText("1 headers")).toBeTruthy()
+ expect(getByText("1 header")).toBeTruthy()
+ })
+
+ it("counts a single mapped field in the singular", () => {
+ const { getByText } = renderScreen(encode({ fieldMap: { lat: "latitude" } }))
+ expect(getByText("1 field")).toBeTruthy()
})
it("rejects invalid interval (negative)", () => {
@@ -366,6 +371,13 @@ describe("SetupImportScreen", () => {
expect(getByText("100m")).toBeTruthy()
})
+ it("never shows a zone named Endpoint as the server, because the name is the link writer's text", () => {
+ const { getByText, queryByText } = renderScreen(encode({ geofences: [{ ...validGeofence, name: "Endpoint" }] }))
+ expect(queryByText("Sends locations to")).toBeNull()
+ expect(getByText("Endpoint")).toBeTruthy()
+ expect(getByText("100m")).toBeTruthy()
+ })
+
it("rejects a geofence missing required fields", () => {
const { getByText } = renderScreen(encode({ geofences: [{ name: "X", lat: 52.5 }] }))
expect(getByText("Invalid configuration")).toBeTruthy()
diff --git a/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx b/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
index 6723b875..ed2017fb 100644
--- a/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
@@ -145,6 +145,15 @@ describe("ShareSetupScreen", () => {
expect(config.auth).toBeUndefined() // credentials not toggled on
})
+ it("counts a single saved zone and profile in the singular", async () => {
+ mockGetGeofences.mockResolvedValue([{ id: 1, name: "Home", lat: 1, lon: 1, radius: 50 }])
+ mockGetProfiles.mockResolvedValue([{ id: 2, name: "Driving" }])
+ const { findByText } = render(<ShareSetupScreen />)
+
+ expect(await findByText("1 zone")).toBeTruthy()
+ expect(await findByText("1 profile")).toBeTruthy()
+ })
+
it("disables the credentials toggle when none are configured", async () => {
const { getByTestId } = render(<ShareSetupScreen />)
await waitFor(() => expect(mockGetAuthConfig).toHaveBeenCalled())
diff --git a/apps/mobile/src/utils/__tests__/logCapture.test.ts b/apps/mobile/src/utils/__tests__/logCapture.test.ts
index 91d72374..5ea806a4 100644
--- a/apps/mobile/src/utils/__tests__/logCapture.test.ts
+++ b/apps/mobile/src/utils/__tests__/logCapture.test.ts
@@ -1,6 +1,6 @@
import type { MergedLogEntry } from "../logExport"
import {
- CAPTURE_HINT,
+ captureHint,
countByFloor,
DEFAULT_LOG_FLOOR,
deleteSub,
@@ -8,7 +8,7 @@ import {
floorOptions,
levelLetter,
levelWord,
- LOG_CONTENTS_LINE,
+ logContentsLine,
logTime,
nextStepLine,
passesFloor,
@@ -64,7 +64,7 @@ describe("the wording a reporter acts on", () => {
})
it("says logging survives a restart, which is the fact reporters get wrong", () => {
- expect(CAPTURE_HINT).toContain("restarts included")
+ expect(captureHint()).toContain("restarts included")
})
/**
@@ -74,11 +74,11 @@ describe("the wording a reporter acts on", () => {
* echoes the payload it refused puts them in the file anyway.
*/
it("names what leaves the device, and stops short of promising an absence", () => {
- expect(LOG_CONTENTS_LINE).toContain("geofences")
- expect(LOG_CONTENTS_LINE).toContain("tracking profiles")
- expect(LOG_CONTENTS_LINE).toContain("server host")
- expect(LOG_CONTENTS_LINE).toContain("Colota writes no coordinates")
- expect(LOG_CONTENTS_LINE).toMatch(/rejected upload can carry your server/)
+ expect(logContentsLine()).toContain("geofences")
+ expect(logContentsLine()).toContain("tracking profiles")
+ expect(logContentsLine()).toContain("server host")
+ expect(logContentsLine()).toContain("Colota writes no coordinates")
+ expect(logContentsLine()).toMatch(/rejected upload can carry your server/)
})
it("says the capture continues after a delete, only when it does", () => {
diff --git a/apps/mobile/src/utils/__tests__/setupLink.test.ts b/apps/mobile/src/utils/__tests__/setupLink.test.ts
index d1eae192..70af54e5 100644
--- a/apps/mobile/src/utils/__tests__/setupLink.test.ts
+++ b/apps/mobile/src/utils/__tests__/setupLink.test.ts
@@ -90,6 +90,8 @@ describe("setupLink", () => {
expect(result.config.settings.accuracyThreshold).toBe(50)
expect(result.config.settings.syncInterval).toBe(0)
expect(result.config.settings.endpoint).toBe("https://example.com/api")
+ // The import screen finds the endpoint by this id to give it its own block; the label translates.
+ expect(result.entries.find((e) => e.field === "endpoint")?.value).toBe("https://example.com/api")
expect(result.config.settings.apiTemplate).toBe("custom")
expect(result.config.settings.fieldMap).toEqual({ lat: "latitude" })
// credentials map authType -> type and keep secrets + headers
diff --git a/apps/mobile/src/utils/logCapture.ts b/apps/mobile/src/utils/logCapture.ts
index 6b9bbf76..56dfb197 100644
--- a/apps/mobile/src/utils/logCapture.ts
+++ b/apps/mobile/src/utils/logCapture.ts
@@ -9,6 +9,7 @@ import type { LogLevel } from "./logger"
import type { MergedLogEntry } from "./logExport"
import { formatBytes } from "./format"
import { formatTimeIn } from "./geo"
+import { t } from "../i18n/t"
/**
* What a log capture is worth handing over, in the words the screen prints.
@@ -29,10 +30,9 @@ export const DEFAULT_LOG_FLOOR: LogFloor = "all"
* that echoes the payload it refused puts coordinates in the file through the back door. An
* absolute "holds no coordinates" would be false exactly when it mattered.
*/
-export const LOG_CONTENTS_LINE =
- "The file names your geofences, your tracking profiles and your server host. Colota writes no coordinates into it, but a rejected upload can carry your server's reply. Read it before you attach it."
+export const logContentsLine = () => t("log.contents")
-export const CAPTURE_HINT = "Keeps writing until you switch it off, restarts included."
+export const captureHint = () => t("log.captureHint")
export interface CaptureState {
icon: LucideIcon
@@ -48,20 +48,24 @@ export interface CaptureState {
export function describeCapture(enabled: boolean, bytes: number, startedAtMs: number): CaptureState {
if (enabled) {
if (bytes === 0) {
- return { icon: FileClock, tone: "recording", label: "Recording", caption: "Nothing written yet" }
+ return { icon: FileClock, tone: "recording", label: t("log.recording"), caption: t("log.nothingWritten") }
}
- const since = startedAtMs > 0 ? ` since ${formatTimeIn(Math.floor(startedAtMs / 1000), "24h", false)}` : " written"
- return { icon: FileClock, tone: "recording", label: "Recording", caption: `${formatBytes(bytes)}${since}` }
+ const size = formatBytes(bytes)
+ const caption =
+ startedAtMs > 0
+ ? t("log.since", { size, time: formatTimeIn(Math.floor(startedAtMs / 1000), "24h", false) })
+ : t("log.written", { size })
+ return { icon: FileClock, tone: "recording", label: t("log.recording"), caption }
}
if (bytes > 0) {
return {
icon: FileText,
tone: "idle",
- label: "Not recording",
- caption: `${formatBytes(bytes)} kept from an earlier capture`
+ label: t("log.notRecording"),
+ caption: t("log.kept", { size: formatBytes(bytes) })
}
}
- return { icon: FileX, tone: "idle", label: "Not recording", caption: "No log file on this device" }
+ return { icon: FileX, tone: "idle", label: t("log.notRecording"), caption: t("log.noFile") }
}
/**
@@ -69,23 +73,20 @@ export function describeCapture(enabled: boolean, bytes: number, startedAtMs: nu
* bridge decides and nothing has ever said out loud.
*/
export function previewRowSub(enabled: boolean): string {
- return enabled ? "The log file's most recent lines" : "The system log's last few minutes"
+ return enabled ? t("log.preview.file") : t("log.preview.system")
}
/** The step that is missing from every bug report: leave it on while you reproduce the problem. */
export function nextStepLine(enabled: boolean): string {
- return enabled
- ? "Nothing written yet. Leave this on while you reproduce the problem, then come back and save the file."
- : "Switch on Record a log file, reproduce the problem, then come back and save the file."
+ return enabled ? t("log.next.on") : t("log.next.off")
}
export function deleteSub(bytes: number, enabled: boolean): string {
- const carries = enabled ? " Recording carries on into a new file." : ""
- return `Removes ${formatBytes(bytes)}.${carries}`
+ return t(enabled ? "log.delete.subCarries" : "log.delete.sub", { size: formatBytes(bytes) })
}
export function deleteConfirmMessage(bytes: number): string {
- return `Deletes ${formatBytes(bytes)} of recorded log. Anything you have not saved is gone for good.`
+ return t("log.delete.confirm", { size: formatBytes(bytes) })
}
/**
@@ -93,10 +94,9 @@ export function deleteConfirmMessage(bytes: number): string {
* Never called with no lines at all: the empty state owns that screen, head and count included.
*/
export function resultLine(shown: number, total: number, fromFile: boolean): string {
- const source = fromFile ? "log file" : "system log"
- const noun = total === 1 ? "line" : "lines"
- if (shown === total) return `${total.toLocaleString()} ${noun} from the ${source}`
- return `${shown.toLocaleString()} of ${total.toLocaleString()} ${noun} from the ${source}`
+ const n = total.toLocaleString()
+ if (shown === total) return t(fromFile ? "log.result.file" : "log.result.system", { count: total, n })
+ return t(fromFile ? "log.resultOf.file" : "log.resultOf.system", { count: total, n, shown: shown.toLocaleString() })
}
const FLOOR_RANK: Record<LogFloor, number> = { all: 0, info: 1, warn: 2, error: 3 }
@@ -126,10 +126,10 @@ export function floorOptions(
counts: Record<LogFloor, number>
): readonly { value: LogFloor; label: string; testID: string }[] {
return [
- { value: "all", label: `All ${counts.all.toLocaleString()}`, testID: "floor-all" },
- { value: "info", label: `Info ${counts.info.toLocaleString()}`, testID: "floor-info" },
- { value: "warn", label: `Warnings ${counts.warn.toLocaleString()}`, testID: "floor-warn" },
- { value: "error", label: `Errors ${counts.error.toLocaleString()}`, testID: "floor-error" }
+ { value: "all", label: t("log.floor.all", { n: counts.all.toLocaleString() }), testID: "floor-all" },
+ { value: "info", label: t("log.floor.info", { n: counts.info.toLocaleString() }), testID: "floor-info" },
+ { value: "warn", label: t("log.floor.warn", { n: counts.warn.toLocaleString() }), testID: "floor-warn" },
+ { value: "error", label: t("log.floor.error", { n: counts.error.toLocaleString() }), testID: "floor-error" }
]
}
@@ -147,7 +147,7 @@ export function levelLetter(level: LogLevel): string {
}
export function levelWord(level: LogLevel): string {
- return level.charAt(0) + level.slice(1).toLowerCase()
+ return t(`log.level.${level}`)
}
/** One node per line for TalkBack, rather than one node holding three thousand lines. */
diff --git a/apps/mobile/src/utils/setupConfig.ts b/apps/mobile/src/utils/setupConfig.ts
index c577cb2a..84b71055 100644
--- a/apps/mobile/src/utils/setupConfig.ts
+++ b/apps/mobile/src/utils/setupConfig.ts
@@ -22,6 +22,7 @@ import {
type ProfileConditionType,
type AuthType
} from "../types/global"
+import { t } from "../i18n/t"
export type ImportGeofence = Omit<Geofence, "id" | "createdAt">
export type ImportProfile = Omit<TrackingProfile, "id" | "createdAt">
@@ -34,6 +35,8 @@ export interface ParsedConfig {
}
export interface ConfigEntry {
+ /** A stable id; `label` is display text and translates, so never compare it. */
+ field: string
label: string
value: string
category: "tracking" | "api" | "auth" | "geofence" | "profile"
@@ -80,7 +83,7 @@ export function validateConfig(raw: unknown): ValidationResult {
valid: false,
config: { settings: {}, auth: null, geofences: [], profiles: [] },
entries: [],
- error: "Invalid configuration format"
+ error: t("setup.err.format")
}
}
@@ -93,9 +96,9 @@ export function validateConfig(raw: unknown): ValidationResult {
if ("endpoint" in obj && typeof obj.endpoint === "string" && obj.endpoint.length > 0) {
const rejection = !isEndpointAllowed(obj.endpoint)
- ? "HTTP not allowed for public hosts"
+ ? t("setup.err.publicHttp")
: setupEndpointHost(obj.endpoint) === null
- ? "The server address must be a plain host, without user@ or a backslash"
+ ? t("setup.err.host")
: null
// A link is written by someone else, so one rejected address rejects all of it rather than applying the rest.
if (rejection) {
@@ -103,66 +106,98 @@ export function validateConfig(raw: unknown): ValidationResult {
valid: false,
config: { settings: {}, auth: null, geofences: [], profiles: [] },
entries: [],
- error: `${rejection}. Nothing from this link will be applied.`
+ error: t("setup.err.rejected", { reason: rejection })
}
}
settings.endpoint = obj.endpoint
- entries.push({ label: "Endpoint", value: obj.endpoint, category: "api" })
+ entries.push({ field: "endpoint", label: t("setup.field.endpoint"), value: obj.endpoint, category: "api" })
}
// --- Tracking settings ---
if ("interval" in obj && typeof obj.interval === "number" && obj.interval > 0) {
settings.interval = obj.interval
- entries.push({ label: "Interval", value: `${obj.interval}s`, category: "tracking" })
+ entries.push({
+ field: "interval",
+ label: t("setup.field.interval"),
+ value: `${obj.interval}${t("unit.s")}`,
+ category: "tracking"
+ })
}
if ("distance" in obj && typeof obj.distance === "number" && obj.distance >= 0) {
settings.distance = obj.distance
- entries.push({ label: "Distance threshold", value: `${obj.distance}m`, category: "tracking" })
+ entries.push({
+ field: "distanceThreshold",
+ label: t("setup.field.distanceThreshold"),
+ value: `${obj.distance}m`,
+ category: "tracking"
+ })
}
if ("syncInterval" in obj && typeof obj.syncInterval === "number" && obj.syncInterval >= 0) {
settings.syncInterval = obj.syncInterval
entries.push({
- label: "Sync interval",
- value: obj.syncInterval === 0 ? "Instant" : `${obj.syncInterval}s`,
+ field: "syncInterval",
+ label: t("setup.field.syncInterval"),
+ value: obj.syncInterval === 0 ? t("syncInterval.instant") : `${obj.syncInterval}${t("unit.s")}`,
category: "tracking"
})
}
if ("retryInterval" in obj && typeof obj.retryInterval === "number" && obj.retryInterval >= 0) {
settings.retryInterval = obj.retryInterval
- entries.push({ label: "Retry interval", value: `${obj.retryInterval}s`, category: "tracking" })
+ entries.push({
+ field: "retryInterval",
+ label: t("setup.field.retryInterval"),
+ value: `${obj.retryInterval}${t("unit.s")}`,
+ category: "tracking"
+ })
}
if ("accuracyThreshold" in obj && typeof obj.accuracyThreshold === "number" && obj.accuracyThreshold > 0) {
settings.accuracyThreshold = obj.accuracyThreshold
- entries.push({ label: "Accuracy threshold", value: `${obj.accuracyThreshold}m`, category: "tracking" })
+ entries.push({
+ field: "accuracyThreshold",
+ label: t("setup.field.accuracyThreshold"),
+ value: `${obj.accuracyThreshold}m`,
+ category: "tracking"
+ })
}
if ("filterInaccurateLocations" in obj && typeof obj.filterInaccurateLocations === "boolean") {
settings.filterInaccurateLocations = obj.filterInaccurateLocations
entries.push({
- label: "Filter inaccurate",
- value: obj.filterInaccurateLocations ? "Yes" : "No",
+ field: "filterInaccurate",
+ label: t("setup.field.filterInaccurate"),
+ value: obj.filterInaccurateLocations ? t("common.yes") : t("common.no"),
category: "tracking"
})
}
if ("isOfflineMode" in obj && typeof obj.isOfflineMode === "boolean") {
settings.isOfflineMode = obj.isOfflineMode
- entries.push({ label: "Offline mode", value: obj.isOfflineMode ? "Yes" : "No", category: "tracking" })
+ entries.push({
+ field: "offlineMode",
+ label: t("setup.field.offlineMode"),
+ value: obj.isOfflineMode ? t("common.yes") : t("common.no"),
+ category: "tracking"
+ })
}
if ("syncCondition" in obj && typeof obj.syncCondition === "string") {
settings.syncCondition = obj.syncCondition as any
- entries.push({ label: "Sync condition", value: obj.syncCondition, category: "tracking" })
+ entries.push({
+ field: "syncCondition",
+ label: t("setup.field.syncCondition"),
+ value: obj.syncCondition,
+ category: "tracking"
+ })
}
if ("syncSsid" in obj && typeof obj.syncSsid === "string") {
settings.syncSsid = obj.syncSsid
- entries.push({ label: "Sync SSID", value: obj.syncSsid, category: "tracking" })
+ entries.push({ field: "syncSSID", label: t("setup.field.syncSSID"), value: obj.syncSsid, category: "tracking" })
}
// --- API settings ---
@@ -173,7 +208,7 @@ export function validateConfig(raw: unknown): ValidationResult {
VALID_API_TEMPLATES.includes(obj.apiTemplate as ApiTemplateName)
) {
settings.apiTemplate = obj.apiTemplate as ApiTemplateName
- entries.push({ label: "API template", value: obj.apiTemplate, category: "api" })
+ entries.push({ field: "apiTemplate", label: t("setup.field.apiTemplate"), value: obj.apiTemplate, category: "api" })
}
if (
@@ -182,7 +217,7 @@ export function validateConfig(raw: unknown): ValidationResult {
VALID_HTTP_METHODS.includes(obj.httpMethod as HttpMethod)
) {
settings.httpMethod = obj.httpMethod as HttpMethod
- entries.push({ label: "HTTP method", value: obj.httpMethod, category: "api" })
+ entries.push({ field: "httpMethod", label: t("setup.field.httpMethod"), value: obj.httpMethod, category: "api" })
}
if (
@@ -191,7 +226,12 @@ export function validateConfig(raw: unknown): ValidationResult {
VALID_DAWARICH_MODES.includes(obj.dawarichMode as DawarichMode)
) {
settings.dawarichMode = obj.dawarichMode as DawarichMode
- entries.push({ label: "Dawarich mode", value: obj.dawarichMode, category: "api" })
+ entries.push({
+ field: "dawarichMode",
+ label: t("setup.field.dawarichMode"),
+ value: obj.dawarichMode,
+ category: "api"
+ })
}
if (
@@ -201,7 +241,12 @@ export function validateConfig(raw: unknown): ValidationResult {
obj.overlandBatchSize <= OVERLAND_BATCH_MAX
) {
settings.overlandBatchSize = Math.floor(obj.overlandBatchSize)
- entries.push({ label: "Overland batch size", value: String(settings.overlandBatchSize), category: "api" })
+ entries.push({
+ field: "overlandBatchSize",
+ label: t("setup.field.overlandBatchSize"),
+ value: String(settings.overlandBatchSize),
+ category: "api"
+ })
}
if ("fieldMap" in obj && typeof obj.fieldMap === "object" && obj.fieldMap !== null) {
@@ -216,7 +261,12 @@ export function validateConfig(raw: unknown): ValidationResult {
}
if (hasValid) {
settings.fieldMap = validFieldMap as FieldMap
- entries.push({ label: "Field mapping", value: `${Object.keys(validFieldMap).length} fields`, category: "api" })
+ entries.push({
+ field: "fieldMapping",
+ label: t("setup.field.fieldMapping"),
+ value: t("setup.fields", { count: Object.keys(validFieldMap).length, n: Object.keys(validFieldMap).length }),
+ category: "api"
+ })
}
}
@@ -226,7 +276,12 @@ export function validateConfig(raw: unknown): ValidationResult {
)
if (validFields.length > 0) {
settings.customFields = validFields
- entries.push({ label: "Custom fields", value: `${validFields.length} fields`, category: "api" })
+ entries.push({
+ field: "customFields",
+ label: t("setup.field.customFields"),
+ value: t("setup.fields", { count: validFields.length, n: validFields.length }),
+ category: "api"
+ })
}
}
@@ -238,17 +293,17 @@ export function validateConfig(raw: unknown): ValidationResult {
if ("type" in authObj && typeof authObj.type === "string" && VALID_AUTH_TYPES.includes(authObj.type as AuthType)) {
auth.authType = authObj.type as AuthType
- entries.push({ label: "Auth type", value: authObj.type, category: "auth" })
+ entries.push({ field: "authType", label: t("setup.field.authType"), value: authObj.type, category: "auth" })
}
if ("username" in authObj && typeof authObj.username === "string" && authObj.username.length > 0) {
auth.username = authObj.username
- entries.push({ label: "Username", value: authObj.username, category: "auth" })
+ entries.push({ field: "username", label: t("setup.field.username"), value: authObj.username, category: "auth" })
}
if ("password" in authObj && typeof authObj.password === "string" && authObj.password.length > 0) {
auth.password = authObj.password
- entries.push({ label: "Password", value: "•".repeat(8), category: "auth" })
+ entries.push({ field: "password", label: t("setup.field.password"), value: "•".repeat(8), category: "auth" })
}
if ("bearerToken" in authObj && typeof authObj.bearerToken === "string" && authObj.bearerToken.length > 0) {
@@ -257,7 +312,7 @@ export function validateConfig(raw: unknown): ValidationResult {
authObj.bearerToken.length > 8
? authObj.bearerToken.slice(0, 4) + "•".repeat(4) + authObj.bearerToken.slice(-4)
: "•".repeat(authObj.bearerToken.length)
- entries.push({ label: "Bearer token", value: masked, category: "auth" })
+ entries.push({ field: "bearerToken", label: t("setup.field.bearerToken"), value: masked, category: "auth" })
}
if (Object.keys(auth).length === 0) auth = null
@@ -274,7 +329,12 @@ export function validateConfig(raw: unknown): ValidationResult {
if (Object.keys(validHeaders).length > 0) {
if (!auth) auth = {}
auth.customHeaders = validHeaders
- entries.push({ label: "Custom headers", value: `${Object.keys(validHeaders).length} headers`, category: "auth" })
+ entries.push({
+ field: "customHeaders",
+ label: t("setup.field.customHeaders"),
+ value: t("setup.headers", { count: Object.keys(validHeaders).length, n: Object.keys(validHeaders).length }),
+ category: "auth"
+ })
}
}
@@ -309,7 +369,7 @@ export function validateConfig(raw: unknown): ValidationResult {
heartbeatEnabled: typeof g.heartbeatEnabled === "boolean" ? g.heartbeatEnabled : false,
heartbeatIntervalMinutes: typeof g.heartbeatIntervalMinutes === "number" ? g.heartbeatIntervalMinutes : 15
})
- entries.push({ label: g.name, value: `${g.radius}m`, category: "geofence" })
+ entries.push({ field: "geofence", label: g.name, value: `${g.radius}m`, category: "geofence" })
}
}
@@ -360,7 +420,7 @@ export function validateConfig(raw: unknown): ValidationResult {
enabled: typeof p.enabled === "boolean" ? p.enabled : true,
condition
})
- entries.push({ label: p.name, value: `${p.interval}s`, category: "profile" })
+ entries.push({ field: "profile", label: p.name, value: `${p.interval}${t("unit.s")}`, category: "profile" })
}
}
@@ -369,7 +429,7 @@ export function validateConfig(raw: unknown): ValidationResult {
valid: false,
config: { settings, auth, geofences, profiles },
entries,
- error: "No valid settings found in configuration"
+ error: t("setup.err.none")
}
}