prodap-lore-locale
Version:
Package used to carry out the internationalization of Lore
28 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const promises_1 = require("node:fs/promises");
const node_path_1 = require("node:path");
const filesName = [
'./translation-de-de.json',
'./translation-en-us.json',
'./translation-es-es.json',
'./translation-fr-fr.json',
'./translation-it-it.json',
'./translation-nl-nl.json',
'./translation-pt-br.json',
];
const sortJsonDataItem = async (filename) => {
const filePath = (0, node_path_1.resolve)((0, node_path_1.join)('src', 'translations', filename));
const fileJson = JSON.parse(await (0, promises_1.readFile)(filePath).then(res => res.toString()));
const data = Array.from(fileJson.data);
data.sort((prev, next) => prev.key.localeCompare(next.key));
fileJson.data = data;
await (0, promises_1.writeFile)(filePath, JSON.stringify(fileJson));
};
const main = () => {
return Promise.all(filesName.map(sortJsonDataItem)).then(() => {
console.log('All translation files sorted');
});
};
main();
//# sourceMappingURL=sort-json-data.js.map