2.8.6 • Published 2 years ago

@valueadd/translations-finder v2.8.6

Weekly downloads
245
License
MIT
Repository
github
Last release
2 years ago

Translations Finder

Finds missing translations in your project.

Installation

Install with npm

# Locally
npm i translations-finder

# Globally
npm i -g translations-finder

Usage

import { findMissingTranslations } from "translations-finder";

const missingTranslations = findMissingTranslations(
  definedTranslations,
  globFilePattern,
  regexTranslation,
  regexTranslationKey,
  directory
);

definedTranslations is an object of keys assigned to translations.

{
  common: {
    login: "Login",
    logout: "Logout",
    menu: {
      title: "The Boring Company"
    }
  }
}

globFilePattern is the glob matcher for files.

"{,!(node_modules)/**/}*.html";

regexTransaltion is a regular expression that is supposed to match the translation key or the text that includes the translation key.

// Matches {{ 'common.author' | translate }}
/('+[A-Za-z]+\.[A-Za-z]+')( \| translate)/g;

regexTranslationKey is a an optional parameter which can be used to extract the actual key from the found text.

// Extracts the key common.author from the previous matching.
/([A-Za-z]+(\.[A-Za-z]+)+)+/g;

directory is an optional parameter that is used as a root directory to search in. When not provided, the value is equal to process.cwt().

Example usage

import { findMissingTranslations } from "translations-finder";

preparedTranslations = {
  common: {
    login: "Login",
    logout: "Logout",
    menu: {
      title: "The Boring Company",
    },
  },
};

const missingTranslations = findMissingTranslations(
  preparedTranslations,
  "{,!(node_modules)/**/}*.html",
  /('+[A-Za-z]+\.[A-Za-z]+')( \| translate)/g,
  /([A-Za-z]+(\.[A-Za-z]+)+)+/g
);
2.8.3

2 years ago

2.8.2

2 years ago

2.8.5

2 years ago

2.8.4

2 years ago

2.8.6

2 years ago

2.8.1

2 years ago

2.7.0

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.2

4 years ago

2.5.0

4 years ago

2.5.1

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago