Socket
Socket
Sign inDemoInstall

translation-file-validator

Package Overview
Dependencies
14
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    translation-file-validator

Script to check for missing keys in translation files


Version published
Weekly downloads
46
decreased by-17.86%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 03 Dec 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc