Split page messages

This commit is contained in:
Joseph Garrone
2021-02-28 20:22:18 +01:00
parent 1f1c050467
commit be295ff328
11 changed files with 8343 additions and 8325 deletions

View File

@ -9,8 +9,6 @@ import * as child_process from "child_process";
//@ts-ignore
const propertiesParser = require("properties-parser");
console.log(propertiesParser);
const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44");
child_process.execSync(`rm -rf ${tmpDirPath}`);
@ -46,19 +44,28 @@ crawl(".").forEach(filePath => {
child_process.execSync(`rm -r ${tmpDirPath}`);
const targetFilePath = pathJoin("src", "lib", "i18n", "messages.generated.ts");
const targetDirPath = pathJoin(getProjectRoot(), "src", "lib", "i18n", "generated_messages");
fs.writeFileSync(
pathJoin(getProjectRoot(), targetFilePath),
Buffer.from(
[
`//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`,
'//PLEASE DO NOT EDIT MANUALLY',
'',
'/* spell-checker: disable */',
`export const messages= ${JSON.stringify(record, null, 2)} as const;`,
'/* spell-checker: enable */'
].join("\n"), "utf8")
);
fs.mkdirSync(targetDirPath, { "recursive": true });
console.log(`${targetFilePath} wrote`);
Object.keys(record).forEach(pageType => {
const filePath = pathJoin(targetDirPath, `${pageType}.ts`);
fs.writeFileSync(
filePath,
Buffer.from(
[
`//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`,
'//PLEASE DO NOT EDIT MANUALLY',
'',
'/* spell-checker: disable */',
`export const messages= ${JSON.stringify(record[pageType], null, 2)} as const;`,
'/* spell-checker: enable */'
].join("\n"), "utf8")
);
console.log(`${filePath} wrote`);
});