README
i18n translation files linter.
Info: The README is always up-to-date with the latest commit, check out releases to see the docs for your version!
This linter will do three major things:
- Finding conflicts: Comparing your files against each other to see if there are any properties with types not matching up.
- Finding duplicates: Finding duplicates to reduce redundancy and elimitate duplicate translations.
- Cleanup: Sorting all properties alphabetically which will make working with your file easier and maintain consistency across all your files.
It comes with a CLI and an API.
Gettings started
Install via npm:
$ npm install li18nt
... or using yarn:
$ yarn add li18nt
CLI Usage
Installing it will add li18nt
(and the alias lint-i18n
) to your command line.
Examples:
# Lint all json files in /locales
$ li18nt locales/*.json
# Lint all valid json files in /locales, print out only warnings and errors
$ li18nt locales/*.json --skip-invalid --quiet
# List all commands
$ li18nt --help
Usage: li18nt [files...] [options]
Lints your locales files, lint-i18n is an alias.
Options:
-v, --version Output the current version
-q, --quiet Print only errors and warnings
-d, --debug Debug information
-f, --fix Tries to fix existing errors
--config [path] Configuration file path (it'll try to resolve one in the current directory)
--skip-invalid Skip invalid files without exiting
--report Print system information
-h, --help Show this help text
Li18nt is configuration drive, you'll need to add a configuration. It'll try to resolve a .li18ntrc
, .li18nt.json
,.li18ntrc.json
or li18nt.config.js
in the current directory. Use the --config [path]
option to specify a different path.
The Li18nt config file is usually located in locales/.li18nt or in your root folder.
{
// Override the --quiet cli option
"quiet": false,
// Override the --skip-invalid cli option
// If this is set to false it'll exit immediately after a file couldn't be parsed or read
"skipInvalid": false,
// List of rules
"rules": {
// Checks if your files are properly formatted,
// you can also just pass "warn" as value - 4 spaces are default
"prettified": ["warn", {"indent": "tab"}],
// Checks for conflicts
"conflicts": "warn",
// Validate property names
"naming": ["warn", {
// Specify a list of regular expressions to match keys against
"patterns": [
"^[a-z]*