translation-file-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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 TranslationFiles 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             │
└──────────┴────────────────────────────┘

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    41
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    41
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i translation-file-validator

Weekly Downloads

41

Version

1.0.2

License

MIT

Unpacked Size

18.1 kB

Total Files

17

Last publish

Collaborators

  • alrico88