From ccdc4dee56e9fce5ef271c6a0333465c3c8ff6ef Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:32:37 +0200 Subject: [PATCH] fix: add the template settings strings to the catalog TemplateSettings calls the translate function `tr` because `t` is a template variable there, and both the key harvester and the coverage test only looked for `t('...')`. Ten of its keys were never added to locales/rn/en.json, so they could not be translated and the test did not notice. Both now also match `tr('...')`, and the missing keys are added. --- locales/rn/en.json | 11 ++++++++++- scripts/harvest-rn-keys.mjs | 7 ++++--- src/i18n/__tests__/keys.test.ts | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/locales/rn/en.json b/locales/rn/en.json index aeabcaa4..f32f685c 100644 --- a/locales/rn/en.json +++ b/locales/rn/en.json @@ -866,7 +866,16 @@ "plugins": "Plugins" }, "templates": { - "delete_title": "Delete template" + "delete_confirm": "Permanently delete \"{name}\"?", + "delete_title": "Delete template", + "description_mobile": "Reusable snippets for common replies. Tap one to edit; long-press to delete.", + "export_failed": "Export failed", + "import_failed": "Import failed", + "imported": "Imported", + "imported_count": "{count, plural, one {# template} other {# templates}} added.", + "is_html": "Body is HTML", + "placeholders_hint": "Placeholders: {{recipient_name}}, {{company}}, {{date}}, {{day_of_week}}, {{sender_name}}", + "share_unavailable": "Unable to share" }, "themes": { "default_description": "The default light and dark palettes.", diff --git a/scripts/harvest-rn-keys.mjs b/scripts/harvest-rn-keys.mjs index 15831ab8..c7875aaa 100644 --- a/scripts/harvest-rn-keys.mjs +++ b/scripts/harvest-rn-keys.mjs @@ -61,9 +61,10 @@ const overlayFlat = flatten(overlay); // t('key', 'fallback') / t('key', "fallback") / t('key', `fallback`) - the // fallback may span lines; keep it simple: single-quoted or double-quoted, -// non-nested strings. -const CALL_RE = /\bt\(\s*'([^']+)'\s*,\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")/g; -const KEY_ONLY_RE = /\bt\(\s*'([^']+)'/g; +// non-nested strings. `tr` is the same function where `t` is taken (a +// template or timer variable). +const CALL_RE = /\btr?\(\s*'([^']+)'\s*,\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")/g; +const KEY_ONLY_RE = /\btr?\(\s*'([^']+)'/g; const added = []; const missingNoFallback = []; diff --git a/src/i18n/__tests__/keys.test.ts b/src/i18n/__tests__/keys.test.ts index d73c8992..08b515db 100644 --- a/src/i18n/__tests__/keys.test.ts +++ b/src/i18n/__tests__/keys.test.ts @@ -34,10 +34,10 @@ function walk(dir: string, out: string[] = []): string[] { return out; } -// Literal keys: t('a.b.c', …). Template-literal keys (`settings.tabs.${id}`) -// are checked by prefix below. -const LITERAL_KEY_RE = /\bt\(\s*'([^']+)'/g; -const TEMPLATE_KEY_RE = /\bt\(\s*`([^`$]+)\$\{/g; +// Literal keys: t('a.b.c', …), or tr(…) where `t` is taken. Template-literal +// keys (`settings.tabs.${id}`) are checked by prefix below. +const LITERAL_KEY_RE = /\btr?\(\s*'([^']+)'/g; +const TEMPLATE_KEY_RE = /\btr?\(\s*`([^`$]+)\$\{/g; // Walking and reading all of src/ synchronously takes under a second on its // own, but went past the 5 s default (16.8 s) while gradle was building.