From d63216e7ba8dddbc180fb5d001038ed8f13bd193 Mon Sep 17 00:00:00 2001 From: L <162464326+rue-eru@users.noreply.github.com> Date: Tue, 23 Jun 2026 11:21:51 +0000 Subject: [PATCH 1/2] feat: add locale keys validation script (#166) --- package.json | 3 ++- scripts/validate-locales.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 scripts/validate-locales.js diff --git a/package.json b/package.json index d879c0a..ccf9f3b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "test": "vitest", "test:watch": "vitest --watch", "redis:up": "docker compose up -d redis", - "redis:down": "docker compose stop redis" + "redis:down": "docker compose stop redis", + "validate-locales": "node scripts/validate-locales.js" }, "dependencies": { "@octokit/graphql": "^9.0.3", diff --git a/scripts/validate-locales.js b/scripts/validate-locales.js new file mode 100644 index 0000000..31cccf0 --- /dev/null +++ b/scripts/validate-locales.js @@ -0,0 +1,21 @@ +const fs = require('fs'); +const path = require('path'); + +const localesDir = path.join(__dirname, '..', 'locales'); +const enKeys = Object.keys(JSON.parse(fs.readFileSync(path.join(localesDir, 'en.json'), 'utf8'))).sort(); + +let hasError = false; + +fs.readdirSync(localesDir).forEach(file => { + if (file === 'en.json') return; + + const fileKeys = Object.keys(JSON.parse(fs.readFileSync(path.join(localesDir, file), 'utf8'))).sort(); + const missing = enKeys.filter(k => !fileKeys.includes(k)); + const extra = fileKeys.filter(k => !enKeys.includes(k)); + if (missing.length || extra.length) { + hasError = true; + console.error(`${file}: ${missing.length ? `Missing keys: ${missing.join(', ')}` : ''}${extra.length ? ` Extra keys: ${extra.join(', ')}` : ''}`); + } +}); + +process.exit(hasError ? 1 : 0); \ No newline at end of file From 6c7cfa00bcb7c0a13a02d0de982b83ab6e5e8ba6 Mon Sep 17 00:00:00 2001 From: Osama Mabkhot <99215291+O2sa@users.noreply.github.com> Date: Tue, 23 Jun 2026 23:02:39 +0300 Subject: [PATCH 2/2] fix(validate-locales.js): Add ESLint disable comment for require imports --- scripts/validate-locales.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/validate-locales.js b/scripts/validate-locales.js index 31cccf0..e34f91a 100644 --- a/scripts/validate-locales.js +++ b/scripts/validate-locales.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-require-imports */ const fs = require('fs'); const path = require('path'); @@ -18,4 +19,4 @@ fs.readdirSync(localesDir).forEach(file => { } }); -process.exit(hasError ? 1 : 0); \ No newline at end of file +process.exit(hasError ? 1 : 0);