Global

Members

(constant) defaultConfig :Config

Type:
Source:

(constant) mergedConfig :Types.Config

Type:
  • Types.Config
Source:

Methods

checkForDuplicateValues(translation, config) → {void}

Check for duplicate values in translation file
Parameters:
Name Type Description
translation Map The translation file
config Types.Config The config for the validator
Source:
Returns:
Type
void

getCodeKeys(file, config) → {Array.<string>}

Get all code keys from the given file using the regex array from the config
Parameters:
Name Type Description
file string The file to check
config Types.Config The config for the validator
Source:
Returns:
Returns an array with all matches
Type
Array.<string>

loadJsonFiles(config) → {Array.<string>}

returns all json files locales directory
Parameters:
Name Type Description
config Types.Config The config for the validator
Source:
Returns:
Returns an array with all json files
Type
Array.<string>

loadTranslation(translationFile) → {Map}

Load the translation file and return it as a Map
Parameters:
Name Type Description
translationFile string // Location of the translation file
Source:
Returns:
Returns the translation
Type
Map

missingKeysInCode(translation, codeKeys, config) → {void}

Check for missing keys in code
Parameters:
Name Type Description
translation Map The translation file
codeKeys Array.<string> The keys from the code
config Types.Config The config for the validator
Source:
Returns:
Type
void

missingKeysInTranslation(translation, codeKeys, config) → {void}

Check for missing keys in translation file
Parameters:
Name Type Description
translation Map The translation file
codeKeys Array.<string> The keys from the code
config Types.Config The config for the validator
Source:
Returns:
Type
void

readFiles(dir) → {Array.<string>}

Read all files in the given directory
Parameters:
Name Type Description
dir string The directory to read
Source:
Returns:
Returns an array with all .jsx and .tsx files
Type
Array.<string>

traverse(node, map, path) → {Map.<string, string>}

Traverse the translation object and add the key-value pairs to a map
Parameters:
Name Type Description
node Object The current node
map Map.<string, string> The map with the key-value pairs
path Array.<string> The path of the current node
Source:
Returns:
The map with the key-value pairs
Type
Map.<string, string>

traverse(node, map, path, filterTheseopt, codeCheckopt) → {Array.<string>}

Traverse the translation object and add the key-value pairs to a map
Parameters:
Name Type Attributes Description
node Object The current node
map Map.<string, string> The map with the key-value pairs
path Array.<string> The path of the current node
filterThese Array.<string> <optional>
The keys to filter out
codeCheck boolean <optional>
Check for code keys
Source:
Returns:
The map with the key-value pairs
Type
Array.<string>

Type Definitions

Config

The default config for the validator
Type:
  • Object
Properties:
Name Type Attributes Description
errorLevel 'warn' | 'error' | 'off' <optional>
The error level
regex Array.<RegExp> <optional>
The regex to find the translation keys in the source files
src string The source folder
directory string The directory of the translation files
ignoreKeys Array.<string> <optional>
The keys to ignore
Source: