From 21fd11ce30497775d112993cd9ab712242088390 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Sun, 26 Jul 2026 13:37:31 +0700 Subject: [PATCH] fix(i18n): plural forms, the count the retrofit missed, and error text that re-translates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Last batch from the Phase 4 adversarial review, including one the completeness critic caught that none of the six lenses looked for. The num() retrofit was incomplete: FolderPickNode rendered its per-folder count raw, so a Vietnamese user saw "12345" in the export pick tree while StatsCard showed "12.345" on the adjacent tab. docs/07 §3, written in this same phase, enumerates exactly three exemptions and this was on none of them. ImportTab resolved t('errors.…') inside a catch block and stored the resulting STRING in the session store. t() is only reactive where it is called, so the error message froze in whatever language was active when it happened and never followed a language switch. Phase 4 is what makes that observable -- until now there was no way to switch language at runtime. The store holds the key now. docs/07 §5 specifies plural keys as { one, other } objects in every locale with a helper that selects by locale. No such helper existed and the dictionaries used "(s)" instead, which produced "1 unreadable date(s) were left blank." -- wrong in more ways than the parenthesis. selectPluralForm uses Intl.PluralRules (en gives one/other, vi/ja only ever other, so two forms cover every locale we ship) and tPlural supplies a locale-grouped {n} so callers pass a raw count. All seven warning codes are plural keys, including the two that interpolate no count, so WarningList can call tPlural unconditionally instead of maintaining a list of which codes count things. Also splits getGeneratorVersion from getAppVersion: the UI hides an unknown version, but a file field cannot be hidden, and "BookmarkMagic " with a trailing space is a worse artifact in an export -- and in the forced Replace safety backup -- than the bare product name. Co-Authored-By: Claude Opus 5 --- src/lib/browser/app-info.ts | 13 +++++++ src/lib/components/FolderPickNode.svelte | 4 +-- src/lib/components/ImportTab.svelte | 21 +++++++---- src/lib/components/WarningList.svelte | 6 ++-- src/lib/export/run-export.ts | 4 +-- src/lib/i18n/format.ts | 21 +++++++++++ src/lib/i18n/index.svelte.ts | 29 ++++++++++++++- src/lib/i18n/locales/en.ts | 45 ++++++++++++++++++----- src/lib/i18n/locales/ja.ts | 41 +++++++++++++++------ src/lib/i18n/locales/vi.ts | 39 +++++++++++++++----- src/lib/import/run-import.ts | 4 +-- src/lib/stores/import-session.svelte.ts | 10 +++++- tests/unit/i18n/dictionaries.test.ts | 30 ++++++++++++---- tests/unit/i18n/format.test.ts | 46 ++++++++++++++++++++++-- 14 files changed, 260 insertions(+), 53 deletions(-) diff --git a/src/lib/browser/app-info.ts b/src/lib/browser/app-info.ts index 9f1748b..12ed395 100644 --- a/src/lib/browser/app-info.ts +++ b/src/lib/browser/app-info.ts @@ -24,3 +24,16 @@ export function getAppVersion(): string { return ''; } } + +/** + * The `generator` string written into exported and backup BM JSON. + * + * Separate from `getAppVersion` because the UI and a file want different + * fallbacks: the UI hides an unknown version, but a file field cannot be + * hidden, and `"BookmarkMagic "` with a trailing space is a worse artifact + * than the bare product name. + */ +export function getGeneratorVersion(): string { + const version = getAppVersion(); + return version === '' ? 'unknown' : version; +} diff --git a/src/lib/components/FolderPickNode.svelte b/src/lib/components/FolderPickNode.svelte index c53b688..81d71f7 100644 --- a/src/lib/components/FolderPickNode.svelte +++ b/src/lib/components/FolderPickNode.svelte @@ -1,7 +1,7 @@