Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

translation-file-validator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translation-file-validator

Script to check for missing keys in translation files

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
decreased by-56.25%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 03 Dec 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc