Hermetiska integrationstester + auto-hushall i onboarding (size, i18n, locations)

This commit is contained in:
Sven (AAMOS AI)
2026-08-06 22:06:11 +07:00
parent dd66ebedbf
commit 3696aadf98
12 changed files with 9079 additions and 44 deletions
+31
View File
@@ -0,0 +1,31 @@
import { readFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const cache: Record<string, Record<string, string>> = {};
/**
* Minimal server-side i18n lookup into the mobile app's common.json files.
* Falls back to the requested key if the translation is missing.
*/
export function t(key: string, languageTag: string): string {
const lang = (languageTag.split("-")[0] ?? languageTag).toLowerCase();
let dict = cache[lang];
if (!dict) {
try {
const file = path.resolve(
__dirname,
"../../../../apps/mobile/src/locales",
lang,
"common.json",
);
dict = JSON.parse(readFileSync(file, "utf8")) as Record<string, string>;
} catch {
dict = {};
}
cache[lang] = dict;
}
return dict[key] ?? key;
}