Skip to content

Commit

Permalink
chore: add hooks for updating the translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jan 22, 2025
1 parent ae69d52 commit 03fbbd1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hooks/update-translation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import path from "node:path";
/**
* Update the locale submodules
*/
console.log("<> Updating locale submodules <>");
execSync("cd src/i18n/locales && git checkout main && git pull");

const i18nPath = path.resolve("src/i18n/i18next.ts");
Expand All @@ -25,6 +26,7 @@ let importText = "/** ---- IMPORT TRANSLATIONS ---- */\n";
* @Param {Record<string, {translation: string}>} resources
*/
const resources = {};
console.log("<> Parsing i18n files in the src/i18n/locales folder <>");
for (const files of i18nFiles) {
let locale = files.split(".")[0];
if (locale.includes("-")) {
Expand Down Expand Up @@ -52,6 +54,8 @@ newI18nContent = newI18nContent.replace(
/\/\*\* ---- RESOURCE OBJECT ---- \*\/[\s\S]*\/\*\* ---- RESOURCE OBJECT ---- \*\//,
resourceObject
);
console.log("<> Updating i18next.ts file <>");
fs.writeFileSync(i18nPath, newI18nContent);
//run biome
console.log("<> Linting i18next.ts file <>");
execSync("biome format src/i18n/i18next.ts --write");

0 comments on commit 03fbbd1

Please sign in to comment.