Files
web/scripts/i18n/syncDefaultMessage/syncFile.ts
Joakim Jäderberg aafad9781f Merged in feat/lokalise-rebuild (pull request #2993)
Feat/lokalise rebuild

* chore(lokalise): update translation ids

* chore(lokalise): easier to switch between projects

* chore(lokalise): update translation ids

* .

* .

* .

* .

* .

* .

* chore(lokalise): update translation ids

* chore(lokalise): update translation ids

* .

* .

* .

* chore(lokalise): update translation ids

* chore(lokalise): update translation ids

* .

* .

* chore(lokalise): update translation ids

* chore(lokalise): update translation ids

* chore(lokalise): new translations

* merge

* switch to errors for missing id's

* merge

* sync translations


Approved-by: Linus Flood
2025-10-22 11:00:03 +00:00

26 lines
595 B
TypeScript

import fs from "fs";
import { syncIntlFormatMessage } from "./syncIntlFormatMessage";
export function syncFile({
path,
translations,
}: {
path: string;
translations: Record<string, string>;
}) {
if (!fs.existsSync(path)) {
throw new Error(`File not found: ${path}`);
}
const content = fs.readFileSync(path, "utf-8");
const { fileContent, updated } = syncIntlFormatMessage({
translations,
fileContent: content,
});
if (updated) {
fs.writeFileSync(path, fileContent, "utf-8");
}
return { updated, fileContent };
}