Files
vnidrop/localization/src/config.ts
cdricms ef42875ddb feat(apple): generate type-safe L10n accessors and migrate all key literals
Replaces every stringly-typed localization key in the Apple app with
compile-time-checked accessors generated from localization/strings.json.
A mistyped key is now a build error instead of a silent fallback to the
raw key at runtime. The runtime path is unchanged: plain keys are
String.LocalizationValue constants resolved with String(localized:) and
Apple's String Catalog still does the lookup; keys with arguments become
typed, named functions applying args through String(format:).

Generator: new renderSwiftAccessors emits apple/VniDrop/Generated/L10n.swift,
wired into generate. Renamed generic arg1/arg2 tokens on four keys to
semantic names (receiver, transferName, deviceId) and updated their context
notes; positional output is unchanged so .xcstrings (bar the 4 comments)
and the Android XML regenerate identical.

Migration: every key-carrying value flipped to String.LocalizationValue
end to end, resolved only at the leaf. Zero key literals and zero
LocalizedStringKey remain in app or test code. macOS build passes; iOS
test run pending.
2026-07-23 17:12:43 +02:00

37 lines
1.3 KiB
TypeScript

import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
/** Repo root = parent of the localization/ directory. */
export const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
export const LOC_DIR = join(REPO_ROOT, "localization");
export const STRINGS_JSON = join(LOC_DIR, "strings.json");
/** Apple String Catalog — one file, all languages nested. */
export const APPLE_XCSTRINGS = join(
REPO_ROOT,
"apple/VniDrop/Resources/Localizable.xcstrings",
);
/** Apple app Info.plist — its CFBundleLocalizations is kept in sync with supportedLanguages. */
export const APPLE_INFO_PLIST = join(
REPO_ROOT,
"apple/VniDrop/Resources/Info.plist",
);
/** Generated Swift accessors (`L10n`) for compile-time-checked catalog keys. */
export const APPLE_L10N_SWIFT = join(
REPO_ROOT,
"apple/VniDrop/Generated/L10n.swift",
);
/** KMP / Compose Multiplatform resources root; one values[-lang]/strings.xml per language. */
export const KMP_RESOURCES = join(
REPO_ROOT,
"shared/src/commonMain/composeResources",
);
/** Directory holding a language's strings.xml under the compose resources root. */
export function kmpValuesDir(lang: string, sourceLanguage: string): string {
return lang === sourceLanguage ? "values" : `values-${lang}`;
}