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
26 lines
595 B
TypeScript
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 };
|
|
}
|