Registry / testing / i18n-lint

i18n-lint

JSON →
library1.1.0jsnpmunverified

i18n-lint (v1.1.0) is a CLI and library tool for detecting hardcoded (untranslated) strings in HTML and template source files. It checks text nodes and attributes (default: alt, placeholder, title) against a list of built-in internationalization functions like `gettext()` and `i18n()`. Supports custom template delimiters (e.g., {{ }}, <%%>) for Mustache/Handlebars/EJS. Compiled with JSHint-compatible reporters and built-in default/unix/json output. Designed for Node.js >=0.8.0, with global install providing the `i18n-lint` binary. Key differentiator: it integrates linting into existing build pipelines via CLI or Node API, unlike gettext extraction tools.

npm install i18n-lint
INSTALL
IMPORT
SIG · I18N-LINT
I
i18n-lint
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

i18n-lint
import i18nLint from 'i18n-lint'; const results = i18nLint('file.html');
const i18nLint = require('i18n-lint');
Package uses ESM exports. CJS require() may not work due to module format.
cli
import { run } from 'i18n-lint/cli.js'; run(['file.html']);
const run = require('i18n-lint/cli').run;
CLI entry point exposed for programmatic use; ensure correct path.
Linter
import { Linter } from 'i18n-lint'; const linter = new Linter({ templateDelimiters: ['{{', '}}'] });
const Linter = require('i18n-lint').Linter;
Linter class available from main export. Requires options object.

Basic usage: lint an HTML string for hardcoded text, logging results.

import i18nLint from 'i18n-lint'; // Lint a string with default options const results = i18nLint('<p>Hello, world!</p>'); console.log(results); // Output: Array of error objects like { line: 1, col: 3, message: 'Possible untranslated string...' }
i18n-lint --version
Debug
Known issues
gotchaTemplate delimiters option must be a comma-separated string or array, but if passed incorrectly may cause no errors to be reported.
fix
Use -t "{{,}}" for CLI or templateDelimiters: ['{{', '}}'] for API.
affects: >=1.0.0
gotchaDefault attributes checked are alt, placeholder, title; other attributes like data-* or aria-* are ignored unless specified via -a or attributes option.
fix
Use --attributes "aria-label,custom-attr" to include more.
affects: >=1.0.0
gotchaThe tool may report false positives for strings that are actually used as keys in a translation function but not recognized due to missing function patterns.
fix
Configure custom translation function names via options or .i18n-lintrc config file.
affects: >=1.0.0
gotchaExit code 1 indicates hardcoded strings found; exit code 0 means clean. Exit code 64 for usage errors.
fix
Use --help for usage. Ensure input files exist.
affects: >=1.0.0
deprecatedOptions via .i18n-lintrc (YAML) are supported but undocumented; may change.
fix
Consider using programmatic API or CLI flags instead.
affects: >=1.0.0
breakingVersion 1.0.0 dropped support for Node <0.8.0 and changed default reporters.
fix
Update to latest version (1.1.0). If using custom reporter, ensure compatibility.
affects: >=1.0.0 <1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'i18n-lint'
Package not installed or installed globally but not in node_modules.
fix
Run `npm install i18n-lint` or `npm install -g i18n-lint`.
TypeError: i18nLint is not a function
Incorrect import (e.g., default import used on CJS build).
fix
Use `import i18nLint from 'i18n-lint'` if using ESM; otherwise if CJS, use `const i18nLint = require('i18n-lint').default`.
Error: Repoter "custom.js" not found
Path to custom reporter file is incorrect or file doesn't exist.
fix
Use absolute path or ensure file is relative to current working directory. E.g., `--reporter /path/to/reporter.js`.
SyntaxError: Unexpected token ILLEGAL (in template parsing)
Template delimiters not matching actual template syntax.
fix
Specify correct delimiters with -t option, e.g., -t "{{,}}" for Handlebars, -t "<%,%>" for EJS.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
commanderoptionalCLI option parsing
chalkoptionalColored terminal output
lodashrequiredUtility functions (e.g., array/string operations)
js-yamloptionalConfiguration file parsing
extendrequiredObject merging for options
Agent activity
4 hits · last 30 days
node
4
Resources
i18n-lint — npm install i18n-lint · libregistry