Skip to content

Colota - Android GPS Location tracker

refactor(i18n): move Data management and Export & import into the catalog (#910)

Max Dietrich1ccf8ad41b1d
diff --git a/apps/mobile/src/components/ui/ExportFormatDialog.tsx b/apps/mobile/src/components/ui/ExportFormatDialog.tsx
index e33bd346..f795700e 100644
--- a/apps/mobile/src/components/ui/ExportFormatDialog.tsx
+++ b/apps/mobile/src/components/ui/ExportFormatDialog.tsx
@@ -14,6 +14,7 @@ import { Button } from "./Button"
import { DialogShell } from "./DialogShell"
import { Divider } from "./Divider"
import { ListItem } from "./ListItem"
+import { t } from "../../i18n/t"
type ExportFormatDialogProps = {
visible: boolean
@@ -31,7 +32,7 @@ export function ExportFormatDialog({ visible, title, message, onSelect, onReques
visible={visible}
title={title}
onRequestClose={onRequestClose}
- footer={<Button variant="ghost" title="Cancel" onPress={onRequestClose} testID="export-cancel" />}
+ footer={<Button variant="ghost" title={t("common.cancel")} onPress={onRequestClose} testID="export-cancel" />}
>
<Text style={[styles.message, { color: colors.textSecondary }]}>{message}</Text>
<View style={styles.rows}>
@@ -40,7 +41,7 @@ export function ExportFormatDialog({ visible, title, message, onSelect, onReques
{i > 0 && <Divider tight />}
<ListItem
label={EXPORT_FORMATS[key].label}
- sub={EXPORT_FORMATS[key].description}
+ sub={t(EXPORT_FORMATS[key].descriptionKey)}
trailingIcon={Upload}
onPress={() => onSelect(key)}
testID={`export-${key}`}
diff --git a/apps/mobile/src/components/ui/__tests__/ExportFormatDialog.test.tsx b/apps/mobile/src/components/ui/__tests__/ExportFormatDialog.test.tsx
index 98bccc53..725106d0 100644
--- a/apps/mobile/src/components/ui/__tests__/ExportFormatDialog.test.tsx
+++ b/apps/mobile/src/components/ui/__tests__/ExportFormatDialog.test.tsx
@@ -2,6 +2,7 @@ import React from "react"
import { render, fireEvent } from "@testing-library/react-native"
import { EXPORT_FORMAT_KEYS, EXPORT_FORMATS } from "../../../utils/exportConverters"
import { ExportFormatDialog } from "../ExportFormatDialog"
+import { t } from "../../../i18n/t"
jest.mock("../../../hooks/useTheme", () => ({
useTheme: () => ({ colors: require("@colota/shared").lightColors })
@@ -27,7 +28,7 @@ describe("ExportFormatDialog", () => {
expect(getByText("Wed, Sep 3 · 3 trips · 12.4 km")).toBeTruthy()
for (const key of EXPORT_FORMAT_KEYS) {
expect(getByText(EXPORT_FORMATS[key].label)).toBeTruthy()
- expect(getByText(EXPORT_FORMATS[key].description)).toBeTruthy()
+ expect(getByText(t(EXPORT_FORMATS[key].descriptionKey))).toBeTruthy()
}
})
diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.json
index 56b59395..89c935ea 100644
--- a/apps/mobile/src/i18n/locales/en.json
+++ b/apps/mobile/src/i18n/locales/en.json
@@ -696,5 +696,184 @@
"dashboard.locationOff.confirm": "Location settings",
"dashboard.locationOff.cancel": "Start anyway",
"dashboard.stop": "Stop tracking",
- "dashboard.start": "Start tracking"
+ "dashboard.start": "Start tracking",
+ "data.locations_one": "{{n}} location",
+ "data.locations_other": "{{n}} locations",
+ "data.days_one": "{{n}} day",
+ "data.days_other": "{{n}} days",
+ "data.queuedLocations_one": "{{n}} queued location",
+ "data.queuedLocations_other": "{{n}} queued locations",
+ "data.syncedLocations_one": "{{n}} synced location",
+ "data.syncedLocations_other": "{{n}} synced locations",
+ "data.queued.some_one": "{{n}} location waiting to upload. Nothing else holds a copy, and they leave History too.",
+ "data.queued.some_other": "{{n}} locations waiting to upload. Nothing else holds a copy, and they leave History too.",
+ "data.synced.some_one": "{{n}} location already on your server. Imported locations count as synced.",
+ "data.synced.some_other": "{{n}} locations already on your server. Imported locations count as synced.",
+ "data.delete.never_one": "{{n}} of them has never been uploaded, so no copy of it survives.",
+ "data.delete.never_other": "{{n}} of them have never been uploaded, so no copy of those survives.",
+ "data.setTo_one": "Set to {{n}} day",
+ "data.setTo_other": "Set to {{n}} days",
+ "data.syncIdle_one": "{{n}} queued. Uploads it now, whatever Sync only on says.",
+ "data.syncIdle_other": "{{n}} queued. Uploads them now, whatever Sync only on says.",
+ "data.queued.none": "Nothing queued.",
+ "data.synced.none": "Nothing has been uploaded yet.",
+ "data.older.none": "Nothing on this device is older than {{days}}.",
+ "data.older.some": "{{locations}} recorded before {{date}}.",
+ "data.delete.queued.title": "Delete {{locations}}?",
+ "data.delete.queued.message": "These are the locations themselves, not their pending uploads. Once deleted, no copy survives anywhere and they leave History too. Points already handed to your server during a running sync may still arrive. This cannot be undone.",
+ "data.delete.synced.title": "Delete {{locations}}?",
+ "data.delete.synced.message": "Removes {{locations}} from this device, not an upload record. Those days leave History, notes included, and locations you imported count as synced. Copies already on your server stay there. This cannot be undone.",
+ "data.delete.older.title": "Delete {{locations}} older than {{days}}?",
+ "data.delete.older.message": "Removes every location recorded before {{date}} from this device.{{never}} Those days leave History. Copies already on your server stay there. This cannot be undone.",
+ "data.delete.all.title": "Delete all {{locations}}?",
+ "data.delete.all.message": "Removes every location on this device, its upload queue and every manual trip split and merge you made. History becomes empty. Your settings, geofences and profiles stay, and copies already on your server are not touched. This cannot be undone.",
+ "data.delete.all.confirm": "Delete all",
+ "data.atMost": "At most {{n}} days",
+ "unit.days": "days",
+ "unit.day": "day",
+ "data.nothingToDelete.title": "Nothing to delete",
+ "data.nothingToDelete.message": "That count came back empty. The figures above are current.",
+ "data.deleteFailed.title": "Delete failed",
+ "data.deleteFailed.message": "The database reported an error. Check the figures above before trying again.",
+ "data.sync.progress": "Sent {{sent}} of {{total}}.",
+ "data.sync.noAnswer": "No answer from the tracking service. Check the queued count above.",
+ "data.sync.stillQueued": "{{n}} still queued; press again.",
+ "data.sync.someFailed": "Some uploads failed.",
+ "data.sync.failed.title": "Sync failed",
+ "data.sync.failed.message": "Check your connection settings and try again.",
+ "data.compact.released": "Released {{size}}",
+ "data.compact.nothing": "Nothing to release",
+ "data.compact.failed.title": "Could not compact",
+ "data.compact.failed.message": "The database is busy. Try again in a moment.",
+ "data.sync.noServer": "No server configured. Set one on Connection.",
+ "data.sync.nothingLast": "Nothing queued. Last upload {{when}}.",
+ "data.sync.nothingAuto": "Nothing queued. New locations upload on their own.",
+ "data.deleting": "Deleting…",
+ "data.counting": "Counting…",
+ "data.age.fix": "Fix the age below.",
+ "data.age.choose": "Choose how old a location must be.",
+ "data.section.stored": "Stored on this device",
+ "data.stat.locations": "Locations",
+ "data.stat.size": "Database size",
+ "data.section.maintenance": "Maintenance",
+ "data.syncNow": "Sync now",
+ "data.syncNow.hint": "Uploads the queue now",
+ "data.compact": "Compact database",
+ "data.compact.running": "Rewriting the database…",
+ "data.compact.sub": "Gives unused space back. Deletes nothing.",
+ "data.compact.hint": "Rewrites the database file",
+ "data.section.delete": "Delete locations",
+ "data.empty.title": "Nothing stored",
+ "data.empty.hint": "This device has no locations yet.",
+ "data.backupFirst": "Back up first",
+ "data.backupFirst.sub": "A backup is the only way to bring any of this back.",
+ "data.deleteQueued": "Delete queued locations",
+ "data.deleteSynced": "Delete synced locations",
+ "data.deleteOlder": "Delete older locations",
+ "data.confirmThenDelete": "Asks you to confirm, then deletes",
+ "data.age": "Age",
+ "data.age.year": "1 year",
+ "data.olderThan": "Delete locations older than",
+ "data.olderThan.hint": "At least 1 day.",
+ "data.deleteAll": "Delete all locations",
+ "transfer.newLocations_one": "{{n}} new location",
+ "transfer.newLocations_other": "{{n}} new locations",
+ "transfer.duplicates_one": "{{n}} duplicate",
+ "transfer.duplicates_other": "{{n}} duplicates",
+ "transfer.unusableRows_one": "{{n}} unusable row",
+ "transfer.unusableRows_other": "{{n}} unusable rows",
+ "transfer.files_one": "{{n}} file",
+ "transfer.files_other": "{{n}} files",
+ "transfer.exportAll_one": "All {{n}} location in one file, oldest first. The file goes to the app you pick and is not kept here.",
+ "transfer.exportAll_other": "All {{n}} locations in one file, oldest first. The file goes to the app you pick and is not kept here.",
+ "transfer.exported_one": "Exported {{n}} location as {{format}} and handed the file over.",
+ "transfer.exported_other": "Exported {{n}} locations as {{format}} and handed the file over.",
+ "transfer.queueHint_one": "Sends {{n}} location to your server too.",
+ "transfer.queueHint_other": "Sends {{n}} locations to your server too.",
+ "transfer.importCount_one": "Import {{n}} location",
+ "transfer.importCount_other": "Import {{n}} locations",
+ "transfer.confirm.title_one": "Import {{n}} location?",
+ "transfer.confirm.title_other": "Import {{n}} locations?",
+ "formats.legacyLabel": "{{name}} (legacy)",
+ "formats.geojson.description": "QGIS, Mapbox, Leaflet. One point per recording, and the only format Colota re-imports without losing a field.",
+ "formats.google_timeline_legacy.description": "Older bulk Location History export from Google Takeout. Google removed this from Takeout in late 2024; use this for archived files.",
+ "formats.google_timeline_new.description": "On-device export from Android Settings -> Location -> Location services -> Timeline.",
+ "formats.gpx.description": "GPS Exchange Format - Garmin, Strava, sport watches, tracking apps.",
+ "formats.kml.description": "Google Earth, Google Maps, ArcGIS.",
+ "formats.csv.description": "Comma-separated table - Excel, Google Sheets, data analysis.",
+ "transfer.nothingToExport": "Nothing to export yet.",
+ "transfer.nothingToExportRow": "Nothing to export yet",
+ "transfer.everyLocation": "Every location in one file",
+ "transfer.shareFailed": "The file was written but no app took it. Try again and pick a different app.",
+ "transfer.reading": "Reading the file…",
+ "transfer.backupFirst": "An import cannot be undone. A backup is the only way back.",
+ "transfer.span": "{{from}} to {{to}}",
+ "transfer.skipping": "Skipping {{parts}}.",
+ "transfer.and": "{{first}} and {{second}}",
+ "transfer.confirm.rejected": "A rejected row had no usable time or coordinates.",
+ "transfer.confirm.shared": "Nothing already stored is changed or removed. Duplicates are counted inside the file and against what is stored, and a duplicate is skipped rather than merged.{{rejected}} Recording pauses while these are written, and an import cannot be undone one point at a time.",
+ "transfer.confirm.synced": "{{shared}} They are marked as already uploaded, so Delete synced locations in Data management would take them too.",
+ "transfer.confirm.import": "Import",
+ "transfer.confirm.queued": "{{shared}} Every one becomes an upload to your server, and Colota cannot recall what your server has already taken.",
+ "transfer.confirm.importQueue": "Import and queue",
+ "transfer.empty.none": "No locations were found in this file.",
+ "transfer.err.unsupported": "Colota did not recognise this file. It reads {{formats}}, and it refuses an XML file that declares a DOCTYPE.",
+ "transfer.err.unsupportedCsv": "In a CSV, the header must include latitude, longitude and a time column.",
+ "transfer.err.busy": "Another import is already running.",
+ "transfer.err.expired": "The file you picked expired. Choose it again.",
+ "transfer.err.noServer": "There is no server to queue to. Import without queueing, or set one up on Connection first.",
+ "transfer.err.unreadable": "The file could not be read.",
+ "autoExport.sub.notSetUp": "Not set up yet",
+ "autoExport.sub.noFolder": "No folder chosen",
+ "autoExport.sub.stopped": "Stopped, folder access lost",
+ "autoExport.sub.off": "Off",
+ "autoExport.sub.running": "Export running",
+ "autoExport.sub.kept": "{{files}} kept",
+ "autoExport.sub.lastFailed": "last export failed",
+ "autoExport.interval.daily": "Daily",
+ "autoExport.interval.weekly": "Weekly",
+ "autoExport.interval.monthly": "Monthly",
+ "autoExport.interval.daily.clause": "daily",
+ "autoExport.interval.weekly.clause": "weekly",
+ "autoExport.interval.monthly.clause": "monthly",
+ "transfer.row.autoRunning": "Auto-export export running",
+ "transfer.row.auto": "Auto-export {{summary}}",
+ "transfer.row.autoStopped": "Auto-export stopped, folder access lost",
+ "transfer.row.formats": "{{formats}} in, and out",
+ "transfer.imported_one": "Imported {{n}} location.",
+ "transfer.imported_other": "Imported {{n}} locations.",
+ "transfer.shareSubject": "Colota export",
+ "transfer.exportFailed.title": "Export failed",
+ "transfer.exportFailed.message": "The file could not be written. Try again in a moment.",
+ "transfer.picker.title": "Could not open the picker",
+ "transfer.picker.message": "The system file picker did not open.",
+ "transfer.section.device": "On this device",
+ "transfer.section.export": "Export",
+ "transfer.section.import": "Import",
+ "transfer.exportAllRow": "Export all locations",
+ "transfer.exportAll.hint": "Picks a format, then hands the file to another app",
+ "transfer.exportDayRow": "Export a day or a trip",
+ "transfer.fromHistory": "From History",
+ "transfer.autoRow": "Automatic export",
+ "transfer.alsoQueue": "Also queue for upload",
+ "transfer.importRow": "Import a file",
+ "transfer.importRow.hint": "Opens the file picker",
+ "transfer.formatTitle": "Export format",
+ "transfer.exporting": "Exporting",
+ "transfer.importing": "Importing",
+ "transfer.discard": "Discard",
+ "transfer.committing_one": "{{n}} location. Recording waits until this finishes.",
+ "transfer.committing_other": "{{n}} locations. Recording waits until this finishes.",
+ "transfer.totalLocations_one": "{{n}} location.",
+ "transfer.totalLocations_other": "{{n}} locations.",
+ "transfer.empty.unusable_one": "No usable locations. {{n}} row had no usable time or coordinates.",
+ "transfer.empty.unusable_other": "No usable locations. {{n}} rows had no usable time or coordinates.",
+ "transfer.empty.duplicates_one": "Nothing new. {{n}} point was skipped as a duplicate, counted both inside the file and against what is already stored.",
+ "transfer.empty.duplicates_other": "Nothing new. {{n}} points were skipped as duplicates, counted both inside the file and against what is already stored.",
+ "transfer.importQueue_one": "Import and queue {{n}}",
+ "transfer.importQueue_other": "Import and queue {{n}}",
+ "transfer.confirm.queueTitle_one": "Import and queue {{n}} location?",
+ "transfer.confirm.queueTitle_other": "Import and queue {{n}} locations?",
+ "data.age.days_one": "{{n}} day",
+ "data.age.days_other": "{{n}} days"
}
diff --git a/apps/mobile/src/screens/DataManagementScreen.tsx b/apps/mobile/src/screens/DataManagementScreen.tsx
index 3c64eba7..8ac3e858 100644
--- a/apps/mobile/src/screens/DataManagementScreen.tsx
+++ b/apps/mobile/src/screens/DataManagementScreen.tsx
@@ -40,6 +40,7 @@ import { parseWholeNumber, wholeNumberError } from "../utils/settingsValidation"
import { formatWhen } from "../utils/geo"
import { logger } from "../utils/logger"
import { formatBytes } from "../utils/format"
+import { useTranslation } from "../i18n/useTranslation"
/** Only a placeholder in the custom field. Nothing is selected until the user selects it. */
const PLACEHOLDER_DAYS = 90
@@ -61,6 +62,7 @@ const EMPTY_STATS: DatabaseStats = {
}
export function DataManagementScreen({ navigation }: RootScreenProps<"Data Management">) {
+ const { t } = useTranslation()
const { settings } = useTracking()
const isOfflineMode = settings.isOfflineMode
@@ -121,8 +123,10 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
// The bridge parameter is a Kotlin Int, so an age past its range would arrive coerced and could
// put the cutoff in the future, where every row matches.
const ageError = isCustom
- ? (wholeNumberError(customText, 1, "day") ??
- (customDays !== null && customDays > MAX_RETENTION_DAYS ? `At most ${MAX_RETENTION_DAYS} days` : undefined))
+ ? (wholeNumberError(customText, 1, t("unit.day")) ??
+ (customDays !== null && customDays > MAX_RETENTION_DAYS
+ ? t("data.atMost", { n: MAX_RETENTION_DAYS })
+ : undefined))
: undefined
/** One count per settled age, from the same cutoff arithmetic the delete uses. */
@@ -192,7 +196,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
// delete stays disarmed, which is the right resting state for a delete argument.
if (restored === null) return
setCustomText(String(restored))
- setClampNote(`Set to ${restored} day${restored === 1 ? "" : "s"}`)
+ setClampNote(t("data.setTo", { count: restored, n: restored }))
clampTimeout.set(() => setClampNote(undefined), SAVE_SUCCESS_DISPLAY_MS)
runPreview(restored)
}
@@ -221,7 +225,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
older = { days, unsent, cutoffSeconds }
}
if (count === 0) {
- showAlert("Nothing to delete", "That count came back empty. The figures above are current.", "info")
+ showAlert(t("data.nothingToDelete.title"), t("data.nothingToDelete.message"), "info")
return
}
@@ -234,18 +238,14 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
runPreview(days)
} catch (err) {
logger.error(`[DataManagementScreen] Failed to delete ${scope} locations:`, err)
- showAlert(
- "Delete failed",
- "The database reported an error. Check the figures above before trying again.",
- "error"
- )
+ showAlert(t("data.deleteFailed.title"), t("data.deleteFailed.message"), "error")
} finally {
busyRef.current = false
setBusy(null)
setBusyScope(null)
}
},
- [days, updateStats, runPreview, applyStats]
+ [days, updateStats, runPreview, applyStats, t]
)
const handleManualFlush = useCallback(async () => {
@@ -253,7 +253,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
busyRef.current = true
const queuedBefore = stats.queued
setBusy("flush")
- setSyncMessage({ text: `Sent 0 of ${queuedBefore.toLocaleString()}.` })
+ setSyncMessage({ text: t("data.sync.progress", { sent: 0, total: queuedBefore.toLocaleString() }) })
const finish = async (message: Message) => {
flushTimeout.clear()
@@ -269,10 +269,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
// over a large queue outlives the window while still reporting, and declaring it dead would
// remove the listener and re-enable the button over a run that is still uploading.
const armFallback = () =>
- flushTimeout.set(
- () => finish({ text: "No answer from the tracking service. Check the queued count above.", failed: true }),
- MANUAL_FLUSH_TIMEOUT_MS
- )
+ flushTimeout.set(() => finish({ text: t("data.sync.noAnswer"), failed: true }), MANUAL_FLUSH_TIMEOUT_MS)
const sub = DeviceEventEmitter.addListener(
"onSyncProgress",
@@ -281,15 +278,21 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
// batches, so the running count reaching the queue it started with is not the signal.
if (event.remaining === undefined) {
armFallback()
- setSyncMessage({ text: `Sent ${event.sent.toLocaleString()} of ${queuedBefore.toLocaleString()}.` })
+ setSyncMessage({
+ text: t("data.sync.progress", { sent: event.sent.toLocaleString(), total: queuedBefore.toLocaleString() })
+ })
return
}
// `remaining` is a fresh count of the queue. `failed` counts attempts inside the pass and can
// exceed it, since a row that failed twice is one row, so it never stands in for the queue.
- const sent = `Sent ${event.sent.toLocaleString()} of ${queuedBefore.toLocaleString()}.`
- const left = event.remaining > 0 ? ` ${event.remaining.toLocaleString()} still queued; press again.` : ""
+ const sent = t("data.sync.progress", {
+ sent: event.sent.toLocaleString(),
+ total: queuedBefore.toLocaleString()
+ })
+ const left =
+ event.remaining > 0 ? ` ${t("data.sync.stillQueued", { n: event.remaining.toLocaleString() })}` : ""
if (event.failed > 0) {
- finish({ text: `${sent} Some uploads failed.${left}`, failed: true })
+ finish({ text: `${sent} ${t("data.sync.someFailed")}${left}`, failed: true })
} else {
finish({ text: `${sent}${left}` })
}
@@ -309,9 +312,9 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
busyRef.current = false
setBusy(null)
setSyncMessage(null)
- showAlert("Sync failed", "Check your connection settings and try again.", "error")
+ showAlert(t("data.sync.failed.title"), t("data.sync.failed.message"), "error")
}
- }, [stats.queued, settings.endpoint, updateStats, flushTimeout])
+ }, [stats.queued, settings.endpoint, updateStats, flushTimeout, t])
const handleCompact = useCallback(async () => {
if (busyRef.current) return
@@ -330,57 +333,60 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
applyStats(after, afterGeneration)
const freed = before - after.databaseSizeMB
setCompactMessage({
- text: freed > 0.01 ? `Released ${formatBytes(freed * 1024 * 1024, { decimals: 0 })}` : "Nothing to release"
+ text:
+ freed > 0.01
+ ? t("data.compact.released", { size: formatBytes(freed * 1024 * 1024, { decimals: 0 }) })
+ : t("data.compact.nothing")
})
compactTimeout.set(() => setCompactMessage(null), SAVE_SUCCESS_DISPLAY_MS)
} catch (err) {
logger.error("[DataManagementScreen] Compact failed:", err)
- showAlert("Could not compact", "The database is busy. Try again in a moment.", "error")
+ showAlert(t("data.compact.failed.title"), t("data.compact.failed.message"), "error")
} finally {
busyRef.current = false
setBusy(null)
}
- }, [compactTimeout, applyStats])
+ }, [compactTimeout, applyStats, t])
const syncBlocker = !settings.endpoint
- ? "No server configured. Set one on Connection."
+ ? t("data.sync.noServer")
: stats.queued === 0
? stats.lastSyncTime > 0
- ? `Nothing queued. Last upload ${formatWhen(Math.floor(stats.lastSyncTime / 1000))}.`
- : "Nothing queued. New locations upload on their own."
+ ? t("data.sync.nothingLast", { when: formatWhen(Math.floor(stats.lastSyncTime / 1000)) })
+ : t("data.sync.nothingAuto")
: null
- const syncIdle = `${stats.queued.toLocaleString()} queued. Uploads ${stats.queued === 1 ? "it" : "them"} now, whatever Sync only on says.`
+ const syncIdle = t("data.syncIdle", { count: stats.queued, n: stats.queued.toLocaleString() })
const syncSub = busy === "flush" ? (syncMessage?.text ?? "") : (syncBlocker ?? syncIdle)
const syncResult = busy === "flush" ? null : syncMessage
const scopeProgress = (scope: DataScope) =>
- busyScope === scope ? (busy === "delete" ? "Deleting…" : "Counting…") : null
+ busyScope === scope ? (busy === "delete" ? t("data.deleting") : t("data.counting")) : null
const ageCount = preview && preview.days === days ? preview.total : null
// The field owns its own error; repeating it here would print the same sentence twice.
const ageLine = ageError
- ? "Fix the age below."
+ ? t("data.age.fix")
: days === null
- ? "Choose how old a location must be."
+ ? t("data.age.choose")
: ageCount === null
- ? "Counting…"
+ ? t("data.counting")
: olderSub(ageCount, days, preview?.cutoffSeconds ?? 0)
return (
<Container>
<ScrollView contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled">
<View style={styles.section}>
- <SectionTitle>Stored on this device</SectionTitle>
+ <SectionTitle>{t("data.section.stored")}</SectionTitle>
<Card rows>
<StatRow
icon={MapPin}
- label="Locations"
+ label={t("data.stat.locations")}
value={loaded ? stats.total.toLocaleString() : "…"}
testID="stat-locations"
/>
<Divider tight inset />
<StatRow
icon={HardDrive}
- label="Database size"
+ label={t("data.stat.size")}
value={loaded ? formatBytes(stats.databaseSizeMB * 1024 * 1024, { decimals: 0 }) : "…"}
testID="stat-size"
/>
@@ -388,7 +394,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
</View>
<View style={styles.section}>
- <SectionTitle>Maintenance</SectionTitle>
+ <SectionTitle>{t("data.section.maintenance")}</SectionTitle>
<Card rows>
{!isOfflineMode && (
<>
@@ -396,11 +402,11 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
testID="sync-now-row"
icon={Clock}
trailingIcon={busy === "flush" ? SpinningLoader : CloudUpload}
- label="Sync now"
+ label={t("data.syncNow")}
sub={syncSub}
subLines={2}
disabled={busy === "flush" ? false : isProcessing || syncBlocker !== null}
- accessibilityHint="Uploads the queue now"
+ accessibilityHint={t("data.syncNow.hint")}
onPress={handleManualFlush}
/>
<Divider tight inset />
@@ -410,11 +416,11 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
testID="compact-row"
icon={HardDrive}
trailingIcon={busy === "compact" ? SpinningLoader : Minimize2}
- label="Compact database"
- sub={busy === "compact" ? "Rewriting the database…" : "Gives unused space back. Deletes nothing."}
+ label={t("data.compact")}
+ sub={busy === "compact" ? t("data.compact.running") : t("data.compact.sub")}
subLines={2}
disabled={busy === "compact" ? false : isProcessing}
- accessibilityHint="Rewrites the database file"
+ accessibilityHint={t("data.compact.hint")}
onPress={handleCompact}
/>
</Card>
@@ -425,12 +431,12 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
</View>
<View style={styles.section}>
- <SectionTitle>Delete locations</SectionTitle>
+ <SectionTitle>{t("data.section.delete")}</SectionTitle>
{/* Until the first count lands the screen knows nothing, and "Nothing stored" over a full
database is both a lie and a whole subtree that mounts only to be torn down again. */}
{!loaded ? null : stats.total === 0 ? (
<Card rows style={styles.emptyCard}>
- <EmptyState title="Nothing stored" hint="This device has no locations yet." style={styles.empty} />
+ <EmptyState title={t("data.empty.title")} hint={t("data.empty.hint")} style={styles.empty} />
</Card>
) : (
<>
@@ -438,8 +444,8 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
<ListItem
testID="nav-backup-restore"
icon={Archive}
- label="Back up first"
- sub="A backup is the only way to bring any of this back."
+ label={t("data.backupFirst")}
+ sub={t("data.backupFirst.sub")}
subLines={2}
onPress={() => navigation.navigate("Backup & Restore")}
/>
@@ -450,11 +456,11 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
testID="delete-queued-row"
icon={Clock}
trailingIcon={busyScope === "queued" ? SpinningLoader : Trash2}
- label="Delete queued locations"
+ label={t("data.deleteQueued")}
sub={scopeProgress("queued") ?? scopeSub("queued", stats.queued)}
subLines={2}
disabled={busyScope === "queued" ? false : isProcessing || stats.queued === 0}
- accessibilityHint="Asks you to confirm, then deletes"
+ accessibilityHint={t("data.confirmThenDelete")}
onPress={() => confirmAndDelete("queued", () => NativeLocationService.clearQueue())}
/>
<Divider tight inset />
@@ -462,11 +468,11 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
testID="delete-synced-row"
icon={CloudUpload}
trailingIcon={busyScope === "synced" ? SpinningLoader : Trash2}
- label="Delete synced locations"
+ label={t("data.deleteSynced")}
sub={scopeProgress("synced") ?? scopeSub("synced", stats.sent)}
subLines={2}
disabled={busyScope === "synced" ? false : isProcessing || stats.sent === 0}
- accessibilityHint="Asks you to confirm, then deletes"
+ accessibilityHint={t("data.confirmThenDelete")}
onPress={() => confirmAndDelete("synced", () => NativeLocationService.clearSentHistory())}
/>
</>
@@ -476,23 +482,23 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
testID="delete-older-row"
icon={CalendarRange}
trailingIcon={busyScope === "older" ? SpinningLoader : Trash2}
- label="Delete older locations"
+ label={t("data.deleteOlder")}
sub={scopeProgress("older") ?? ageLine}
subLines={2}
disabled={busyScope === "older" ? false : isProcessing || !!ageError || days === null || !ageCount}
- accessibilityHint="Asks you to confirm, then deletes"
+ accessibilityHint={t("data.confirmThenDelete")}
onPress={() => confirmAndDelete("older", () => NativeLocationService.deleteOlderThan(days as number))}
/>
<View style={styles.ageControls}>
<ChipGroup
- accessibilityLabel="Age"
+ accessibilityLabel={t("data.age")}
options={[
...RETENTION_PRESET_DAYS.map((preset) => ({
value: String(preset),
- label: preset === 365 ? "1 year" : `${preset} days`,
+ label: preset === 365 ? t("data.age.year") : t("data.age.days", { count: preset, n: preset }),
testID: `age-${preset}`
})),
- { value: "custom", label: "Custom", testID: "age-custom" }
+ { value: "custom", label: t("common.custom"), testID: "age-custom" }
]}
selected={ageChoice}
onSelect={handleAgeChoice}
@@ -500,14 +506,14 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
{isCustom && (
<View style={styles.customField}>
<NumericInput
- label="Delete locations older than"
+ label={t("data.olderThan")}
testID="retention-days-input"
value={customText}
onChange={handleCustomChange}
onBlur={handleCustomBlur}
- unit="days"
+ unit={t("unit.days")}
placeholder={String(PLACEHOLDER_DAYS)}
- hint="At least 1 day."
+ hint={t("data.olderThan.hint")}
error={ageError}
message={clampNote}
/>
@@ -519,7 +525,7 @@ export function DataManagementScreen({ navigation }: RootScreenProps<"Data Manag
<Button
variant="danger"
icon={Trash2}
- title="Delete all locations"
+ title={t("data.deleteAll")}
testID="delete-all-btn"
loading={busyScope === "all"}
disabled={isProcessing}
diff --git a/apps/mobile/src/screens/ExportImportScreen.tsx b/apps/mobile/src/screens/ExportImportScreen.tsx
index 0fcda404..a9a51757 100644
--- a/apps/mobile/src/screens/ExportImportScreen.tsx
+++ b/apps/mobile/src/screens/ExportImportScreen.tsx
@@ -44,11 +44,12 @@ import {
importRowSub,
previewHeadline,
queueHint,
- SHARE_FAILED_LINE,
+ shareFailedLine,
skippedLine
} from "../utils/locationTransfer"
import { space } from "../constants"
import type { ScreenProps } from "../types/global"
+import { useTranslation } from "../i18n/useTranslation"
type AutoExportStatus = Awaited<ReturnType<typeof NativeLocationService.getAutoExportStatus>>
type Busy = "export" | "parse" | "commit" | null
@@ -58,6 +59,7 @@ const EMPTY = { total: 0, databaseSizeMB: 0 }
export function ExportImportScreen({ navigation }: ScreenProps) {
const { colors } = useTheme()
+ const { t } = useTranslation()
const [stats, setStats] = useState(EMPTY)
const [loaded, setLoaded] = useState(false)
@@ -115,35 +117,38 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
ImportService.cancelImport().catch(() => {})
}, [dropStaged])
- const handleExport = useCallback(async (format: ExportFormat) => {
- setFormatOpen(false)
- if (busyRef.current !== null) return
- busyRef.current = "export"
- setBusy("export")
- setExportMessage(null)
- try {
- const result = await NativeLocationService.exportToFile(format)
- if (!result) {
- setExportMessage({ text: exportLine(0) })
- return
- }
- // Dismissed before the share sheet, which would otherwise sit over this overlay.
- setBusy(null)
+ const handleExport = useCallback(
+ async (format: ExportFormat) => {
+ setFormatOpen(false)
+ if (busyRef.current !== null) return
+ busyRef.current = "export"
+ setBusy("export")
+ setExportMessage(null)
try {
- await NativeLocationService.shareFile(result.filePath, result.mimeType, `Colota export`)
- setExportMessage({ text: exportResultLine(result.rowCount, format) })
- } catch (shareError) {
- logger.warn("[ExportImportScreen] Share failed:", shareError)
- setExportMessage({ text: SHARE_FAILED_LINE, failed: true })
+ const result = await NativeLocationService.exportToFile(format)
+ if (!result) {
+ setExportMessage({ text: exportLine(0) })
+ return
+ }
+ // Dismissed before the share sheet, which would otherwise sit over this overlay.
+ setBusy(null)
+ try {
+ await NativeLocationService.shareFile(result.filePath, result.mimeType, t("transfer.shareSubject"))
+ setExportMessage({ text: exportResultLine(result.rowCount, format) })
+ } catch (shareError) {
+ logger.warn("[ExportImportScreen] Share failed:", shareError)
+ setExportMessage({ text: shareFailedLine(), failed: true })
+ }
+ } catch (err) {
+ logger.error("[ExportImportScreen] Export failed:", err)
+ showAlert(t("transfer.exportFailed.title"), t("transfer.exportFailed.message"), "error")
+ } finally {
+ busyRef.current = null
+ setBusy(null)
}
- } catch (err) {
- logger.error("[ExportImportScreen] Export failed:", err)
- showAlert("Export failed", "The file could not be written. Try again in a moment.", "error")
- } finally {
- busyRef.current = null
- setBusy(null)
- }
- }, [])
+ },
+ [t]
+ )
const handleChooseFile = useCallback(async () => {
if (busyRef.current !== null) return
@@ -152,7 +157,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
source = await ImportService.pickImportSource()
} catch (err) {
logger.error("[ExportImportScreen] pickImportSource failed:", err)
- showAlert("Could not open the picker", "The system file picker did not open.", "error")
+ showAlert(t("transfer.picker.title"), t("transfer.picker.message"), "error")
return
}
if (!source || busyRef.current !== null) return
@@ -177,7 +182,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
busyRef.current = null
setBusy(null)
}
- }, [])
+ }, [t])
const handleCommit = useCallback(async () => {
if (busyRef.current !== null || !preview) return
@@ -188,7 +193,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
try {
const inserted = await ImportService.commitImport(queued)
dropStaged()
- setImportMessage({ text: `Imported ${inserted.toLocaleString()} locations.` })
+ setImportMessage({ text: t("transfer.imported", { count: inserted, n: inserted.toLocaleString() }) })
await read()
} catch (err) {
logger.error("[ExportImportScreen] Commit failed:", err)
@@ -200,7 +205,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
busyRef.current = null
setBusy(null)
}
- }, [preview, queued, read, dropStaged])
+ }, [preview, queued, read, dropStaged, t])
const skipped = preview ? skippedLine(preview) : undefined
const headline = preview ? previewHeadline(preview) : null
@@ -210,18 +215,18 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
<Container>
<ScrollView contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled">
<View style={styles.section}>
- <SectionTitle>On this device</SectionTitle>
+ <SectionTitle>{t("transfer.section.device")}</SectionTitle>
<Card rows>
<StatRow
icon={MapPin}
- label="Locations"
+ label={t("data.stat.locations")}
value={loaded ? stats.total.toLocaleString() : "…"}
testID="stat-locations"
/>
<Divider tight inset />
<StatRow
icon={HardDrive}
- label="Database size"
+ label={t("data.stat.size")}
value={loaded ? formatBytes(stats.databaseSizeMB * 1024 * 1024, { decimals: 0 }) : "…"}
testID="stat-size"
/>
@@ -229,16 +234,16 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
</View>
<View style={styles.section}>
- <SectionTitle>Export</SectionTitle>
+ <SectionTitle>{t("transfer.section.export")}</SectionTitle>
<Card rows>
{/* Before the first stats read the total is 0, which would read as nothing to export. */}
<ListItem
testID="export-all-row"
icon={MapPin}
trailingIcon={Upload}
- label="Export all locations"
+ label={t("transfer.exportAllRow")}
sub={loaded ? exportRowSub(stats.total) : undefined}
- accessibilityHint="Picks a format, then hands the file to another app"
+ accessibilityHint={t("transfer.exportAll.hint")}
disabled={busy !== null || stats.total === 0}
onPress={() => setFormatOpen(true)}
/>
@@ -246,15 +251,15 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
<ListItem
testID="nav-location-history"
icon={CalendarRange}
- label="Export a day or a trip"
- sub="From History"
+ label={t("transfer.exportDayRow")}
+ sub={t("transfer.fromHistory")}
onPress={() => navigation.navigate("Location History")}
/>
<Divider tight inset />
<ListItem
testID="nav-auto-export"
icon={Clock}
- label="Automatic export"
+ label={t("transfer.autoRow")}
sub={autoExportSub(autoExport)}
subLines={2}
onPress={() => navigation.navigate("Auto-Export")}
@@ -266,7 +271,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
</View>
<View style={styles.section}>
- <SectionTitle>Import</SectionTitle>
+ <SectionTitle>{t("transfer.section.import")}</SectionTitle>
{preview && headline ? (
<>
<Card rows>
@@ -280,11 +285,11 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
{preview.canQueueForSync && (
<>
<Divider tight />
- <SettingRow label="Also queue for upload" hint={queueHint(preview.newRows)}>
+ <SettingRow label={t("transfer.alsoQueue")} hint={queueHint(preview.newRows)}>
<Toggle
value={queued}
onValueChange={setQueued}
- accessibilityLabel="Also queue for upload"
+ accessibilityLabel={t("transfer.alsoQueue")}
testID="queue-toggle"
/>
</SettingRow>
@@ -294,7 +299,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
<ListItem
testID="nav-backup-restore"
icon={Archive}
- label="Back up first"
+ label={t("data.backupFirst")}
sub={backupFirstSub()}
subLines={2}
onPress={() => navigation.navigate("Backup & Restore")}
@@ -310,7 +315,7 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
disabled={busy !== null}
onPress={handleCommit}
/>
- <Button variant="ghost" title="Discard" testID="import-discard-btn" onPress={discard} />
+ <Button variant="ghost" title={t("transfer.discard")} testID="import-discard-btn" onPress={discard} />
</>
) : (
<Card rows>
@@ -318,10 +323,10 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
testID="import-file-row"
icon={FileText}
trailingIcon={busy === "parse" ? SpinningLoader : Download}
- label="Import a file"
+ label={t("transfer.importRow")}
sub={importRowSub(busy === "parse")}
subLines={2}
- accessibilityHint="Opens the file picker"
+ accessibilityHint={t("transfer.importRow.hint")}
disabled={busy === "parse" ? false : busy !== null}
onPress={handleChooseFile}
/>
@@ -335,18 +340,18 @@ export function ExportImportScreen({ navigation }: ScreenProps) {
<ExportFormatDialog
visible={formatOpen}
- title="Export format"
+ title={t("transfer.formatTitle")}
message={exportLine(stats.total)}
onSelect={handleExport}
onRequestClose={() => setFormatOpen(false)}
/>
<LoadingOverlay
visible={busy === "export" || busy === "commit"}
- title={busy === "export" ? "Exporting" : "Importing"}
+ title={busy === "export" ? t("transfer.exporting") : t("transfer.importing")}
message={
busy === "commit" && preview
- ? `${preview.newRows.toLocaleString()} locations. Recording waits until this finishes.`
- : `${stats.total.toLocaleString()} locations.`
+ ? t("transfer.committing", { count: preview.newRows, n: preview.newRows.toLocaleString() })
+ : t("transfer.totalLocations", { count: stats.total, n: stats.total.toLocaleString() })
}
/>
</Container>
diff --git a/apps/mobile/src/utils/__tests__/dataScope.test.ts b/apps/mobile/src/utils/__tests__/dataScope.test.ts
index 8d6d61ac..f217e97c 100644
--- a/apps/mobile/src/utils/__tests__/dataScope.test.ts
+++ b/apps/mobile/src/utils/__tests__/dataScope.test.ts
@@ -81,6 +81,12 @@ describe("deleteCopy", () => {
expect(copy.message).toMatch(/96 of them have never been uploaded, so no copy of those survives/)
})
+ it("words a single unsent match in the singular", () => {
+ const copy = deleteCopy("older", 1, { days: 1, cutoffSeconds: CUTOFF, unsent: 1 })
+ expect(copy.title).toBe("Delete 1 location older than 1 day?")
+ expect(copy.message).toMatch(/1 of them has never been uploaded, so no copy of it survives/)
+ })
+
it("drops the unsent clause from the age case when there is none, leaving one space between sentences", () => {
const copy = deleteCopy("older", 3120, { days: 90, cutoffSeconds: CUTOFF, unsent: 0 })
expect(copy.message).not.toMatch(/never been uploaded/)
diff --git a/apps/mobile/src/utils/__tests__/locationTransfer.test.ts b/apps/mobile/src/utils/__tests__/locationTransfer.test.ts
index e8ab27c3..c6e6c8d6 100644
--- a/apps/mobile/src/utils/__tests__/locationTransfer.test.ts
+++ b/apps/mobile/src/utils/__tests__/locationTransfer.test.ts
@@ -1,5 +1,5 @@
import type { ImportPreview } from "../../services/ImportService"
-import { FILE_FORMATS, IMPORT_FORMAT_ORDER } from "../fileFormats"
+import { IMPORT_FORMAT_ORDER, fileFormatLabel } from "../fileFormats"
import { formatDateWithYear } from "../geo"
import {
autoExportSub,
@@ -52,7 +52,7 @@ describe("readableFormats", () => {
it("folds the legacy Timeline parser into its sibling rather than naming one noun twice", () => {
expect(IMPORT_FORMAT_ORDER).toContain("google_timeline_legacy")
- expect(FILE_FORMATS.google_timeline_legacy.label).toBe("Google Timeline (legacy)")
+ expect(fileFormatLabel("google_timeline_legacy")).toBe("Google Timeline (legacy)")
expect(readableFormats().match(/Google Timeline/g)).toHaveLength(1)
})
})
@@ -239,8 +239,12 @@ describe("autoExportSub", () => {
describe("transferRowSub", () => {
// The auto-export row left the hub, so this row is the only place its failure can surface.
it("carries the auto-export state when there is one", () => {
- // Only the first word is lowered, or the format name comes out as "geojson".
+ // The interval takes its in-sentence form; the format name keeps its own case.
expect(transferRowSub(auto())).toBe("Auto-export daily · GeoJSON · 10 files kept")
+ expect(transferRowSub(auto({ interval: "weekly", lastError: "write" }))).toBe(
+ "Auto-export weekly · GeoJSON · 10 files kept · last export failed"
+ )
+ expect(transferRowSub(auto({ running: true }))).toBe("Auto-export export running")
expect(transferRowSub(auto({ enabled: false, lastError: "permission" }))).toBe(
"Auto-export stopped, folder access lost"
)
diff --git a/apps/mobile/src/utils/dataScope.ts b/apps/mobile/src/utils/dataScope.ts
index bc9551a5..98b1d55e 100644
--- a/apps/mobile/src/utils/dataScope.ts
+++ b/apps/mobile/src/utils/dataScope.ts
@@ -4,6 +4,7 @@
*/
import { formatDateWithYear } from "./geo"
+import { t } from "../i18n/t"
/**
* What each delete on Data management takes, in the words the control and its confirmation use.
@@ -23,18 +24,15 @@ export interface DeleteCopy {
confirmText: string
}
-const plural = (n: number, noun: string) => `${n.toLocaleString()} ${noun}${n === 1 ? "" : "s"}`
+const count = (key: "data.locations" | "data.days" | "data.queuedLocations" | "data.syncedLocations", n: number) =>
+ t(key, { count: n, n: n.toLocaleString() })
/** The sub under a delete row, or the message under a delete button: what this press would take. */
-export function scopeSub(scope: "queued" | "synced", count: number): string {
+export function scopeSub(scope: "queued" | "synced", n: number): string {
if (scope === "queued") {
- return count === 0
- ? "Nothing queued."
- : `${plural(count, "location")} waiting to upload. Nothing else holds a copy, and they leave History too.`
+ return n === 0 ? t("data.queued.none") : t("data.queued.some", { count: n, n: n.toLocaleString() })
}
- return count === 0
- ? "Nothing has been uploaded yet."
- : `${plural(count, "location")} already on your server. Imported locations count as synced.`
+ return n === 0 ? t("data.synced.none") : t("data.synced.some", { count: n, n: n.toLocaleString() })
}
/**
@@ -42,9 +40,9 @@ export function scopeSub(scope: "queued" | "synced", count: number): string {
* because that count reads every matching row and is only worth taking once, on the press, where
* `deleteCopy` says it.
*/
-export function olderSub(count: number, days: number, cutoffSeconds: number): string {
- if (count === 0) return `Nothing on this device is older than ${plural(days, "day")}.`
- return `${plural(count, "location")} recorded before ${formatDateWithYear(cutoffSeconds)}.`
+export function olderSub(n: number, days: number, cutoffSeconds: number): string {
+ if (n === 0) return t("data.older.none", { days: count("data.days", days) })
+ return t("data.older.some", { locations: count("data.locations", n), date: formatDateWithYear(cutoffSeconds) })
}
export interface OlderArgs {
@@ -55,39 +53,34 @@ export interface OlderArgs {
}
/** The confirmation for one delete. Every count comes from a read taken immediately before the dialog. */
-export function deleteCopy(scope: DataScope, count: number, older?: OlderArgs): DeleteCopy {
+export function deleteCopy(scope: DataScope, n: number, older?: OlderArgs): DeleteCopy {
switch (scope) {
case "queued":
return {
- title: `Delete ${plural(count, "queued location")}?`,
- message:
- "These are the locations themselves, not their pending uploads. Once deleted, no copy survives anywhere and they leave History too. Points already handed to your server during a running sync may still arrive. This cannot be undone.",
- confirmText: "Delete"
+ title: t("data.delete.queued.title", { locations: count("data.queuedLocations", n) }),
+ message: t("data.delete.queued.message"),
+ confirmText: t("common.delete")
}
case "synced":
return {
- title: `Delete ${plural(count, "synced location")}?`,
- message: `Removes ${plural(count, "location")} from this device, not an upload record. Those days leave History, notes included, and locations you imported count as synced. Copies already on your server stay there. This cannot be undone.`,
- confirmText: "Delete"
+ title: t("data.delete.synced.title", { locations: count("data.syncedLocations", n) }),
+ message: t("data.delete.synced.message", { locations: count("data.locations", n) }),
+ confirmText: t("common.delete")
}
case "older": {
const { days = 0, cutoffSeconds = 0, unsent = 0 } = older ?? ({} as OlderArgs)
- const never =
- unsent === 0
- ? ""
- : ` ${unsent.toLocaleString()} of them have never been uploaded, so no copy of those survives.`
+ const never = unsent === 0 ? "" : ` ${t("data.delete.never", { count: unsent, n: unsent.toLocaleString() })}`
return {
- title: `Delete ${plural(count, "location")} older than ${plural(days, "day")}?`,
- message: `Removes every location recorded before ${formatDateWithYear(cutoffSeconds)} from this device.${never} Those days leave History. Copies already on your server stay there. This cannot be undone.`,
- confirmText: "Delete"
+ title: t("data.delete.older.title", { locations: count("data.locations", n), days: count("data.days", days) }),
+ message: t("data.delete.older.message", { date: formatDateWithYear(cutoffSeconds), never }),
+ confirmText: t("common.delete")
}
}
case "all":
return {
- title: `Delete all ${plural(count, "location")}?`,
- message:
- "Removes every location on this device, its upload queue and every manual trip split and merge you made. History becomes empty. Your settings, geofences and profiles stay, and copies already on your server are not touched. This cannot be undone.",
- confirmText: "Delete all"
+ title: t("data.delete.all.title", { locations: count("data.locations", n) }),
+ message: t("data.delete.all.message"),
+ confirmText: t("data.delete.all.confirm")
}
}
}
diff --git a/apps/mobile/src/utils/exportConverters.ts b/apps/mobile/src/utils/exportConverters.ts
index 79e3b424..ff4209e2 100644
--- a/apps/mobile/src/utils/exportConverters.ts
+++ b/apps/mobile/src/utils/exportConverters.ts
@@ -5,6 +5,7 @@
import { type LucideIcon } from "lucide-react-native"
import { FILE_FORMATS, IMPORT_FORMAT_ORDER } from "./fileFormats"
+import type { TranslationKey } from "../i18n/options"
// Trip-aware serialization lives natively in ExportConverters.kt (convertTrips,
// reached via NativeLocationService.exportTripsToFile). This module now only
@@ -18,7 +19,7 @@ export const EXPORT_FORMAT_KEYS: ExportFormat[] = IMPORT_FORMAT_ORDER.filter(
export interface ExportFormatConfig {
label: string
- description: string
+ descriptionKey: TranslationKey
icon: LucideIcon
extension: string
mimeType: string
@@ -29,7 +30,7 @@ export const EXPORT_FORMATS: Record<ExportFormat, ExportFormatConfig> = EXPORT_F
const f = FILE_FORMATS[key]
acc[key] = {
label: f.label,
- description: f.description,
+ descriptionKey: f.descriptionKey,
icon: f.icon,
extension: f.extension,
mimeType: f.mimeType!
diff --git a/apps/mobile/src/utils/fileFormats.ts b/apps/mobile/src/utils/fileFormats.ts
index 775fac26..aac67a76 100644
--- a/apps/mobile/src/utils/fileFormats.ts
+++ b/apps/mobile/src/utils/fileFormats.ts
@@ -6,19 +6,19 @@
import { Activity, Database, Globe, Map, MapPin, Table2 } from "lucide-react-native"
import type { LucideIcon } from "lucide-react-native"
import type { ImportFormat } from "../services/ImportService"
+import type { TranslationKey } from "../i18n/options"
+import { t } from "../i18n/t"
-// Single source of truth for per-format metadata, shared by the export and import
-// screens. `description` is the general blurb shown in both menus;
-// `importHint` is an optional import-only caveat appended to
-// it on the import screen (where parsing constraints actually matter).
+// Single source of truth for per-format metadata, shared by the export and import screens.
export interface FileFormat {
+ /** A product name, never translated; `legacy` wraps it in the catalog's "(legacy)". */
label: string
+ legacy?: boolean
icon: LucideIcon
extension: string
exportable: boolean
mimeType?: string // present for every exportable format
- description: string
- importHint?: string
+ descriptionKey: TranslationKey
}
export const FILE_FORMATS: Record<ImportFormat, FileFormat> = {
@@ -28,23 +28,22 @@ export const FILE_FORMATS: Record<ImportFormat, FileFormat> = {
extension: ".geojson",
exportable: true,
mimeType: "application/geo+json",
- description:
- "QGIS, Mapbox, Leaflet. One point per recording, and the only format Colota re-imports without losing a field."
+ descriptionKey: "formats.geojson.description"
},
google_timeline_legacy: {
- label: "Google Timeline (legacy)",
+ label: "Google Timeline",
+ legacy: true,
icon: Database,
extension: "Records.json",
exportable: false,
- description:
- "Older bulk Location History export from Google Takeout. Google removed this from Takeout in late 2024; use this for archived files."
+ descriptionKey: "formats.google_timeline_legacy.description"
},
google_timeline_new: {
label: "Google Timeline",
icon: MapPin,
extension: ".json",
exportable: false,
- description: "On-device export from Android Settings -> Location -> Location services -> Timeline."
+ descriptionKey: "formats.google_timeline_new.description"
},
gpx: {
label: "GPX",
@@ -52,7 +51,7 @@ export const FILE_FORMATS: Record<ImportFormat, FileFormat> = {
extension: ".gpx",
exportable: true,
mimeType: "application/gpx+xml",
- description: "GPS Exchange Format - Garmin, Strava, sport watches, tracking apps."
+ descriptionKey: "formats.gpx.description"
},
kml: {
label: "KML",
@@ -60,8 +59,7 @@ export const FILE_FORMATS: Record<ImportFormat, FileFormat> = {
extension: ".kml",
exportable: true,
mimeType: "application/vnd.google-earth.kml+xml",
- description: "Google Earth, Google Maps, ArcGIS.",
- importHint: "Only timestamped placemarks are read - LineString-only tracks are skipped."
+ descriptionKey: "formats.kml.description"
},
csv: {
label: "CSV",
@@ -69,8 +67,7 @@ export const FILE_FORMATS: Record<ImportFormat, FileFormat> = {
extension: ".csv",
exportable: true,
mimeType: "text/csv",
- description: "Comma-separated table - Excel, Google Sheets, data analysis.",
- importHint: "The header must include latitude, longitude and a time column."
+ descriptionKey: "formats.csv.description"
}
}
@@ -82,3 +79,9 @@ export const IMPORT_FORMAT_ORDER: ImportFormat[] = [
"google_timeline_legacy",
"csv"
]
+
+/** The name a format is shown by: the product name, with "(legacy)" from the catalog where it applies. */
+export function fileFormatLabel(format: ImportFormat): string {
+ const entry = FILE_FORMATS[format]
+ return entry.legacy ? t("formats.legacyLabel", { name: entry.label }) : entry.label
+}
diff --git a/apps/mobile/src/utils/locationTransfer.ts b/apps/mobile/src/utils/locationTransfer.ts
index d08979fd..487badf3 100644
--- a/apps/mobile/src/utils/locationTransfer.ts
+++ b/apps/mobile/src/utils/locationTransfer.ts
@@ -4,9 +4,9 @@
*/
import type { ImportPreview } from "../services/ImportService"
-import { FILE_FORMATS, IMPORT_FORMAT_ORDER } from "./fileFormats"
-import { plural } from "./format"
+import { FILE_FORMATS, IMPORT_FORMAT_ORDER, fileFormatLabel } from "./fileFormats"
import { formatDateWithYear } from "./geo"
+import { t } from "../i18n/t"
/**
* What moving locations across this device's file boundary takes and leaves, in the words the
@@ -28,51 +28,64 @@ type AutoExportState = {
retentionCount: number
}
-const formatLabel = (format: string) => FILE_FORMATS[format as keyof typeof FILE_FORMATS]?.label ?? format.toUpperCase()
+const formatLabel = (format: string) =>
+ Object.prototype.hasOwnProperty.call(FILE_FORMATS, format)
+ ? fileFormatLabel(format as keyof typeof FILE_FORMATS)
+ : format.toUpperCase()
+
+const counted = (
+ key: "transfer.newLocations" | "transfer.duplicates" | "transfer.unusableRows" | "transfer.files",
+ n: number
+) => t(key, { count: n, n: n.toLocaleString() })
/** The formats a file can be read as, from the one table, with the legacy Timeline name folded in. */
export function readableFormats(): string {
- const labels = IMPORT_FORMAT_ORDER.map((format) => FILE_FORMATS[format].label.replace(" (legacy)", ""))
+ const labels = IMPORT_FORMAT_ORDER.map((format) => FILE_FORMATS[format].label)
return [...new Set(labels)].join(", ")
}
/** The format dialog's message, and the result line when an export finds nothing. */
export function exportLine(total: number): string {
- if (total === 0) return "Nothing to export yet."
- return `All ${plural(total, "location")} in one file, oldest first. The file goes to the app you pick and is not kept here.`
+ if (total === 0) return t("transfer.nothingToExport")
+ return t("transfer.exportAll", { count: total, n: total.toLocaleString() })
}
/** The sub on the Export all locations row. */
export function exportRowSub(total: number): string {
- return total === 0 ? "Nothing to export yet" : "Every location in one file"
+ return total === 0 ? t("transfer.nothingToExportRow") : t("transfer.everyLocation")
}
/** After a run. Nothing here claims the file was saved, because nothing saved it. */
export function exportResultLine(rowCount: number, format: string): string {
- return `Exported ${plural(rowCount, "location")} as ${formatLabel(format)} and handed the file over.`
+ return t("transfer.exported", { count: rowCount, n: rowCount.toLocaleString(), format: formatLabel(format) })
}
/** A share the system never started. Logged and swallowed before, so it read as a success. */
-export const SHARE_FAILED_LINE = "The file was written but no app took it. Try again and pick a different app."
+export function shareFailedLine(): string {
+ return t("transfer.shareFailed")
+}
/** The sub on the Import a file row. */
export function importRowSub(reading: boolean): string {
- return reading ? "Reading the file…" : readableFormats()
+ return reading ? t("transfer.reading") : readableFormats()
}
/** The sub on the Back up first row in the staged preview. */
export function backupFirstSub(): string {
- return "An import cannot be undone. A backup is the only way back."
+ return t("transfer.backupFirst")
}
/** The staged file, as a state line: the number that matters, then what it came from and when. */
export function previewHeadline(preview: ImportPreview): { label: string; caption: string } {
const span =
preview.dateRangeStartSec != null && preview.dateRangeEndSec != null
- ? ` · ${formatDateWithYear(preview.dateRangeStartSec)} to ${formatDateWithYear(preview.dateRangeEndSec)}`
+ ? ` · ${t("transfer.span", {
+ from: formatDateWithYear(preview.dateRangeStartSec),
+ to: formatDateWithYear(preview.dateRangeEndSec)
+ })}`
: ""
return {
- label: `${plural(preview.newRows, "new location")}`,
+ label: counted("transfer.newLocations", preview.newRows),
caption: `${formatLabel(preview.format)}${span}`
}
}
@@ -83,19 +96,22 @@ export function previewHeadline(preview: ImportPreview): { label: string; captio
*/
export function skippedLine(preview: ImportPreview): string | undefined {
const parts: string[] = []
- if (preview.duplicates > 0) parts.push(plural(preview.duplicates, "duplicate"))
- if (preview.invalid > 0) parts.push(plural(preview.invalid, "unusable row"))
+ if (preview.duplicates > 0) parts.push(counted("transfer.duplicates", preview.duplicates))
+ if (preview.invalid > 0) parts.push(counted("transfer.unusableRows", preview.invalid))
if (parts.length === 0) return undefined
- return `Skipping ${parts.join(" and ")}.`
+ const joined = parts.length === 2 ? t("transfer.and", { first: parts[0], second: parts[1] }) : parts[0]
+ return t("transfer.skipping", { parts: joined })
}
/** The sub under the queue switch. One upload per row is the part that surprises people. */
export function queueHint(newRows: number): string {
- return `Sends ${plural(newRows, "location")} to your server too.`
+ return t("transfer.queueHint", { count: newRows, n: newRows.toLocaleString() })
}
export function commitLabel(newRows: number, queued: boolean): string {
- return queued ? `Import and queue ${newRows.toLocaleString()}` : `Import ${plural(newRows, "location")}`
+ return queued
+ ? t("transfer.importQueue", { count: newRows, n: newRows.toLocaleString() })
+ : t("transfer.importCount", { count: newRows, n: newRows.toLocaleString() })
}
export interface ConfirmCopy {
@@ -110,62 +126,72 @@ export interface ConfirmCopy {
* the file they picked.
*/
export function commitConfirm(preview: ImportPreview, queued: boolean): ConfirmCopy {
- const rejected = preview.invalid > 0 ? " A rejected row had no usable time or coordinates." : ""
- const shared = `Nothing already stored is changed or removed. Duplicates are counted inside the file and against what is stored, and a duplicate is skipped rather than merged.${rejected} Recording pauses while these are written, and an import cannot be undone one point at a time.`
+ const rejected = preview.invalid > 0 ? ` ${t("transfer.confirm.rejected")}` : ""
+ const shared = t("transfer.confirm.shared", { rejected })
if (!queued) {
return {
- title: `Import ${plural(preview.newRows, "location")}?`,
- message: `${shared} They are marked as already uploaded, so Delete synced locations in Data management would take them too.`,
- confirmText: "Import"
+ title: t("transfer.confirm.title", { count: preview.newRows, n: preview.newRows.toLocaleString() }),
+ message: t("transfer.confirm.synced", { shared }),
+ confirmText: t("transfer.confirm.import")
}
}
return {
- title: `Import and queue ${preview.newRows.toLocaleString()} locations?`,
- message: `${shared} Every one becomes an upload to your server, and Colota cannot recall what your server has already taken.`,
- confirmText: "Import and queue"
+ title: t("transfer.confirm.queueTitle", { count: preview.newRows, n: preview.newRows.toLocaleString() }),
+ message: t("transfer.confirm.queued", { shared }),
+ confirmText: t("transfer.confirm.importQueue")
}
}
/** A parse that staged nothing. Three different reasons that all read as "nothing found" before. */
export function emptyPreviewCopy(preview: ImportPreview): string {
- if (preview.totalParsed === 0 && preview.invalid === 0) return "No locations were found in this file."
- if (preview.totalParsed === 0) {
- return `No usable locations. ${preview.invalid.toLocaleString()} rows had no usable time or coordinates.`
- }
- return `Nothing new. ${preview.duplicates.toLocaleString()} points were skipped as duplicates, counted both inside the file and against what is already stored.`
+ if (preview.totalParsed === 0 && preview.invalid === 0) return t("transfer.empty.none")
+ if (preview.totalParsed === 0)
+ return t("transfer.empty.unusable", { count: preview.invalid, n: preview.invalid.toLocaleString() })
+ return t("transfer.empty.duplicates", { count: preview.duplicates, n: preview.duplicates.toLocaleString() })
}
/** Native error codes, worded from what each one means rather than from a hand-kept list. */
export function importErrorMessage(code: string | undefined): string {
switch (code) {
- case "E_IMPORT_UNSUPPORTED": {
+ case "E_IMPORT_UNSUPPORTED":
// A CSV with a bad header is refused here, before any preview exists.
- const hint = FILE_FORMATS.csv.importHint
- const csv = hint ? ` In a CSV, ${hint.charAt(0).toLowerCase()}${hint.slice(1)}` : ""
- return `Colota did not recognise this file. It reads ${readableFormats()}, and it refuses an XML file that declares a DOCTYPE.${csv}`
- }
+ return `${t("transfer.err.unsupported", { formats: readableFormats() })} ${t("transfer.err.unsupportedCsv")}`
case "E_BUSY":
- return "Another import is already running."
+ return t("transfer.err.busy")
case "E_IMPORT_NO_PENDING":
- return "The file you picked expired. Choose it again."
+ return t("transfer.err.expired")
case "E_IMPORT_SYNC_UNAVAILABLE":
- return "There is no server to queue to. Import without queueing, or set one up on Connection first."
+ return t("transfer.err.noServer")
default:
- return "The file could not be read."
+ return t("transfer.err.unreadable")
}
}
+const INTERVALS = ["daily", "weekly", "monthly"] as const
+const isInterval = (value: string): value is (typeof INTERVALS)[number] =>
+ (INTERVALS as readonly string[]).includes(value)
+
+/** "Daily · GeoJSON · 3 files kept"; `clause` gives the interval its in-sentence form. */
+function scheduleLine(status: AutoExportState, clause: boolean): string {
+ const interval = isInterval(status.interval)
+ ? t(clause ? `autoExport.interval.${status.interval}.clause` : `autoExport.interval.${status.interval}`)
+ : status.interval
+ const parts = [interval, formatLabel(status.format)]
+ if (status.retentionCount > 0)
+ parts.push(t("autoExport.sub.kept", { files: counted("transfer.files", status.retentionCount) }))
+ if (status.lastError) parts.push(t("autoExport.sub.lastFailed"))
+ return parts.join(" · ")
+}
+
/** The Automatic export row, and the hub row that now carries its state. */
export function autoExportSub(status: AutoExportState | null): string {
- if (!status) return "Not set up yet"
- if (status.uri === null) return "No folder chosen"
+ if (!status) return t("autoExport.sub.notSetUp")
+ if (status.uri === null) return t("autoExport.sub.noFolder")
if (!status.enabled) {
- return status.lastError ? "Stopped, folder access lost" : "Off"
+ return status.lastError ? t("autoExport.sub.stopped") : t("autoExport.sub.off")
}
- if (status.running) return "Export running"
- const interval = status.interval.charAt(0).toUpperCase() + status.interval.slice(1)
- const kept = status.retentionCount > 0 ? ` · ${plural(status.retentionCount, "file")} kept` : ""
- return `${interval} · ${formatLabel(status.format)}${kept}${status.lastError ? " · last export failed" : ""}`
+ if (status.running) return t("autoExport.sub.running")
+ return scheduleLine(status, false)
}
/**
@@ -174,10 +200,9 @@ export function autoExportSub(status: AutoExportState | null): string {
*/
export function transferRowSub(status: AutoExportState | null): string {
if (status && status.uri !== null && status.enabled) {
- // Only the first word is lowered. Lowering the whole line would print "geojson".
- const state = autoExportSub(status)
- return `Auto-export ${state.charAt(0).toLowerCase()}${state.slice(1)}`
+ if (status.running) return t("transfer.row.autoRunning")
+ return t("transfer.row.auto", { summary: scheduleLine(status, true) })
}
- if (status?.lastError && !status.enabled) return "Auto-export stopped, folder access lost"
- return `${readableFormats()} in, and out`
+ if (status?.lastError && !status.enabled) return t("transfer.row.autoStopped")
+ return t("transfer.row.formats", { formats: readableFormats() })
}