Skip to content

Commit

Permalink
move update_tracker.mjs out of locales folder to fix vite error
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Jul 4, 2024
1 parent 63bdfb3 commit c39a189
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions frontend/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ tasks:
deps: [ install-https-proxy ]
cmd: pnpm run dev

check-out-of-date-translations:
dir: ./src/lib/i18n
silent: true
cmd: node update_tracker.mjs

Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@ function compileKeys(obj, prefix = '') {
}

function getDiffKeys(stdKeys, lang) {
const langJson = json5.parse(fs.readFileSync(`${lang}.json`, 'utf-8'));
const langJson = json5.parse(fs.readFileSync(lang, 'utf-8'));
const langKeysSet = new Set(compileKeys(langJson, ''));
const diff = stdKeys.filter(x => !langKeysSet.has(x));
return diff;
}

function main() {
const dirname = import.meta.dirname;
const files = fs.readdirSync(dirname);
const localesPath = path.join(import.meta.dirname, 'locales');
const files = fs.readdirSync(localesPath);
const locales = files
.filter(file => path.extname(file).toLowerCase() === '.json')
.map(file => path.basename(file, '.json'))
.filter(file => file !== 'en');
.filter(file => path.extname(file).toLowerCase() === '.json' && file !== 'en.json')
.map(file => path.join(localesPath, file));

const enJson = json5.parse(fs.readFileSync('en.json', 'utf-8'));
const enJson = json5.parse(fs.readFileSync(path.join(localesPath, 'en.json'), 'utf-8'));
const enAllKeys = compileKeys(enJson, '');

const output = {};
Expand Down

0 comments on commit c39a189

Please sign in to comment.