@mok-labs/locales-check

1.0.0 • Public • Published

README

@mok-labs/locales-check

@mok-labs/locales-check is a tiny library designed to identify discrepancies between your locale files by detecting missing keys. It analyzes the combined structure of all your locale files and provides a report on any absent keys. Currently, the library supports only JSON files, which must be stored in the same locales directory.

Content

Why?

When we incorporated multiple languages into our projects, managing consistent keys across all language files became a challenge. Often, some keys were overlooked, and even code reviews occasionally failed to catch these omissions. To address this issue, we implemented this small library to then use it as a check in our Continuous Integration (CI) workflow to identify any missing keys in our locale files.

Usage

Install the package in your project:

With npm

npm install --save-dev @mok-labs/locales-check

With yarn

yarn add -D @mok-labs/locales-check

Use it via script in your package.json file:

{
  "scripts": {
    "locales-check": "npx @mok-labs/locales-check --localesPath='./path/to/locales-files/'"
  }
}

Configuration

localesPath

  • Name: localesPath
  • CLI argument: --localesPath
  • Required: Yes
  • Type: string
  • Description: The path where your locales files are placed
  • Examples: ./path/to/locales-files

ci

  • Name: ci
  • CLI argument: --ci
  • Required: No
  • Default: false
  • Type: boolean
  • Description: Causes the process to exit with exit code 1 if at least one translation key is missing or unused (useful if it is part of a CI pipeline).

License

MIT

Package Sidebar

Install

npm i @mok-labs/locales-check

Weekly Downloads

504

Version

1.0.0

License

MIT

Unpacked Size

34.6 kB

Total Files

25

Last publish

Collaborators

  • moklabs