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
This commit is contained in:
25
scripts/i18n/syncDefaultMessage/syncFile.ts
Normal file
25
scripts/i18n/syncDefaultMessage/syncFile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user