fix(presentation): persist the chosen locale in preferences (R-8.3)

The locale lived only in LocaleProvider state, so every remount (reload,
or the scope fence after a session change) started again from ko-KR.
The theme already persisted through preferences.setColorScheme; the
locale now uses the same path (D-5):

- contracts/storage-keys.ts: LOCALE key next to COLOR_SCHEME
  (localStorage, public-preference, opaque-string-v1).
- application preferences port: additive getLocale()/setLocale(). The
  application treats the tag as opaque; presentation owns the locale
  list and normalizes what it reads back.
- LocaleProvider: optional onLocaleChange; the provider stays
  storage-free so standalone uses and tests are unchanged.
- AppRouter mounts LocaleProvider from the stored locale and persists
  changes (T46 moves this above the scope fence).

Verified: RED "stores the chosen locale and starts the next mount from
it" failed before (nothing written to LOCALE) and passes after.
check:architecture, check:types:app, check:types:test, lint,
test:component pass; check:registries PASS (compatibility unchanged from
baseline); test:unit passes except the pre-existing removal-fixture test
(needs generated artifacts/ files absent from a fresh worktree).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 12:39:51 +09:00
co-authored by Claude Opus 5.5
parent b1a8269d65
commit e5ef6ba236
6 changed files with 79 additions and 4 deletions
+9
View File
@@ -41,6 +41,15 @@ export function createApplication(
const normalized = normalizeColorSchemePreference(preference);
return outputPorts.preferences.write("COLOR_SCHEME", normalized);
},
getLocale(): string | undefined {
const result = outputPorts.preferences.read("LOCALE");
return result.ok && typeof result.value === "string"
? result.value
: undefined;
},
setLocale(locale: string) {
return outputPorts.preferences.write("LOCALE", locale);
},
});
const diagnostics = Object.freeze({
@@ -54,6 +54,9 @@ export type ApplicationApi = Readonly<{
setColorScheme(
preference: ColorSchemePreference,
): ReturnType<StoragePort["write"]>;
/** The stored locale tag, unvalidated; presentation owns the locale list. */
getLocale(): string | undefined;
setLocale(locale: string): ReturnType<StoragePort["write"]>;
}>;
diagnostics: Readonly<{
reportRenderFailure(report: RenderFailureReport): void;