Package Exports
- translation-file-validator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (translation-file-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
translation-checker
Script to check for missing keys in translation files
Installation
Using yarn:
yarn add translation-file-validator -D
Or using npm:
npm i translation-file-validator --save-dev
Usage
Given the following structure:
const es = {
hola: 'mundo',
nested: {
existing: 'both',
missing: 'falta',
},
};
const en = {
goodbye: 'world',
nested: {
existing: 'both',
deepNest: {
missingToo: 'missing',
},
},
};
Create an instance of the checker and pass it an array of TranslationFile
s with the language and the object containing the translations
const {
TranslationChecker,
TranslationFile,
} = require('translation-file-validator');
const languages = [
new TranslationFile('Spanish', es),
new TranslationFile('English', en),
];
const checker = new TranslationChecker(languages);
And run it
checker.check();
It will output a table in your console with the missing keys for each language:
┌──────────┬────────────────────────────┐
│ Language │ Missing translations │
├──────────┼────────────────────────────┤
│ Spanish │ goodbye │
│ │ nested.deepNest.missingToo │
├──────────┼────────────────────────────┤
│ English │ hola │
│ │ nested.missing │
└──────────┴────────────────────────────┘