i18n: wire the display-language translator into the settings manifest

Commonlib's `getConfig(key, translate?)` and `getConfName(key, translate?)`
default `translate` to `englishMessageTranslator`, and this plug-in never
passed the second argument. Every automatically wired setting therefore
rendered its name and description in English, whatever `displayLanguage` was
set to. Commonlib's own Config Doctor already threads a translator through
`getConfName`, so this only restores the argument which was missing here.

`src/modules/features/SettingDialogue/settingConstants.ts` now re-exports the
names it supplies explicitly and adds thin `getConfig` and `getConfName`
wrappers which default the translator to `translateLiveSyncMessage`. That
reaches all three existing call sites, and therefore the 102 `setAuto` and
`autoWire*` calls across the setting panes, the setup-wizard configuration
summaries, and the externally-modified-setting prompt. Of the 225 distinct
name and description strings in the two manifest tables, 160 are already
catalogue keys with translations; the remaining 65 are not catalogue keys and
pass through unchanged.

`ModuleResolveMismatchedTweaks` used `confName()`, which accepts no
translator, so it gains a local `localisedConfName()` instead. Swapping in
`getConfName()` there would have silently dropped the `statusDisplay()`
suffix, replaced the empty-string fallback for an unknown key with
`${key} (No info)`, and introduced `SettingInformation` as a second source.

English output is unchanged: every catalogue key which contains a space has a
value identical to the key itself, so translating under the default language
is idempotent.

Verified with `npm run check`, `npm run test:unit`, and `npm run build`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
nimula
2026-08-20 02:17:20 +00:00
co-authored by Claude Opus 5
parent fbe868092a
commit f8ee3c8662
4 changed files with 127 additions and 6 deletions
@@ -1 +1,37 @@
export * from "@vrtmrz/livesync-commonlib/compat/common/settingConstants";
export {
AllSettingDefault,
OnDialogSettingsDefault,
SettingInformation,
} from "@vrtmrz/livesync-commonlib/compat/common/settingConstants";
export type {
AllSettings,
AllSettingItemKey,
AllStringItemKey,
AllNumericItemKey,
AllBooleanItemKey,
OnDialogSettings,
ValueOf,
} from "@vrtmrz/livesync-commonlib/compat/common/settingConstants";
import {
getConfig as getCommonlibConfig,
getConfName as getCommonlibConfName,
type AllSettingItemKey,
} from "@vrtmrz/livesync-commonlib/compat/common/settingConstants";
import type { MessageTranslator } from "@vrtmrz/livesync-commonlib/context";
import { translateLiveSyncMessage } from "@/common/translation";
// Commonlib defaults `translate` to its English-only translator, so every caller which omits
// it silently renders English regardless of `displayLanguage`. Default it to the LiveSync
// catalogue instead, and re-export these wrappers under the original names so that no call
// site has to remember the second argument.
/** `getConfig` with the LiveSync catalogue applied by default. */
export function getConfig(key: AllSettingItemKey, translate: MessageTranslator = translateLiveSyncMessage) {
return getCommonlibConfig(key, translate);
}
/** `getConfName` with the LiveSync catalogue applied by default. See `getConfig`. */
export function getConfName(key: AllSettingItemKey, translate: MessageTranslator = translateLiveSyncMessage) {
return getCommonlibConfName(key, translate);
}
@@ -0,0 +1,33 @@
import { afterEach, describe, expect, it } from "vitest";
import { setLang } from "@/common/translation";
import { getConfig, getConfName } from "./settingConstants";
describe("setting manifest labels", () => {
afterEach(() => setLang("def"));
it("renders names and descriptions in the selected display language", () => {
setLang("zh-tw");
expect(getConfName("liveSync")).toBe("同步模式");
expect(getConfig("couchDB_URI")).toMatchObject({ name: "伺服器 URI" });
expect(getConfig("encrypt")).toMatchObject({
name: "端對端加密",
desc: "加密遠端資料庫中的內容。如果你使用外掛的同步功能,建議啟用此選項。",
});
});
it("leaves English untouched, so that the catalogue key and its English value stay interchangeable", () => {
expect(getConfName("liveSync")).toBe("Sync Mode");
expect(getConfig("encrypt")).toMatchObject({
name: "End-to-End Encryption",
desc: "Encrypt contents on the remote database. If you use the plugin's synchronization feature, enabling this is recommended.",
});
});
it("passes through labels which Commonlib owns but the catalogue does not carry", () => {
setLang("zh-tw");
expect(getConfName("chunkSplitterVersion")).toBe("Chunk Splitter");
});
});