{"id":25740,"library":"i18n-lint","title":"i18n-lint","description":"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.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/jwarby/i18n-lint","tags":["javascript","hardcoded","strings","i18n","translation","i18n-lint","lint","untranslated","detect"],"install":[{"cmd":"npm install i18n-lint","lang":"bash","label":"npm"},{"cmd":"yarn add i18n-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add i18n-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"CLI option parsing","package":"commander","optional":true},{"reason":"Colored terminal output","package":"chalk","optional":true},{"reason":"Utility functions (e.g., array/string operations)","package":"lodash","optional":false},{"reason":"Configuration file parsing","package":"js-yaml","optional":true},{"reason":"Object merging for options","package":"extend","optional":false}],"imports":[{"note":"Package uses ESM exports. CJS require() may not work due to module format.","wrong":"const i18nLint = require('i18n-lint');","symbol":"i18n-lint","correct":"import i18nLint from 'i18n-lint';\nconst results = i18nLint('file.html');"},{"note":"CLI entry point exposed for programmatic use; ensure correct path.","wrong":"const run = require('i18n-lint/cli').run;","symbol":"cli","correct":"import { run } from 'i18n-lint/cli.js';\nrun(['file.html']);"},{"note":"Linter class available from main export. Requires options object.","wrong":"const Linter = require('i18n-lint').Linter;","symbol":"Linter","correct":"import { Linter } from 'i18n-lint';\nconst linter = new Linter({ templateDelimiters: ['{{', '}}'] });"}],"quickstart":{"code":"import i18nLint from 'i18n-lint';\n// Lint a string with default options\nconst results = i18nLint('<p>Hello, world!</p>');\nconsole.log(results);\n// Output: Array of error objects like { line: 1, col: 3, message: 'Possible untranslated string...' }","lang":"typescript","description":"Basic usage: lint an HTML string for hardcoded text, logging results."},"warnings":[{"fix":"Use -t \"{{,}}\" for CLI or templateDelimiters: ['{{', '}}'] for API.","message":"Template delimiters option must be a comma-separated string or array, but if passed incorrectly may cause no errors to be reported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use --attributes \"aria-label,custom-attr\" to include more.","message":"Default attributes checked are alt, placeholder, title; other attributes like data-* or aria-* are ignored unless specified via -a or attributes option.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Configure custom translation function names via options or .i18n-lintrc config file.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use --help for usage. Ensure input files exist.","message":"Exit code 1 indicates hardcoded strings found; exit code 0 means clean. Exit code 64 for usage errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using programmatic API or CLI flags instead.","message":"Options via .i18n-lintrc (YAML) are supported but undocumented; may change.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Update to latest version (1.1.0). If using custom reporter, ensure compatibility.","message":"Version 1.0.0 dropped support for Node <0.8.0 and changed default reporters.","severity":"breaking","affected_versions":">=1.0.0 <1.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install i18n-lint` or `npm install -g i18n-lint`.","cause":"Package not installed or installed globally but not in node_modules.","error":"Error: Cannot find module 'i18n-lint'"},{"fix":"Use `import i18nLint from 'i18n-lint'` if using ESM; otherwise if CJS, use `const i18nLint = require('i18n-lint').default`.","cause":"Incorrect import (e.g., default import used on CJS build).","error":"TypeError: i18nLint is not a function"},{"fix":"Use absolute path or ensure file is relative to current working directory. E.g., `--reporter /path/to/reporter.js`.","cause":"Path to custom reporter file is incorrect or file doesn't exist.","error":"Error: Repoter \"custom.js\" not found"},{"fix":"Specify correct delimiters with -t option, e.g., -t \"{{,}}\" for Handlebars, -t \"<%,%>\" for EJS.","cause":"Template delimiters not matching actual template syntax.","error":"SyntaxError: Unexpected token ILLEGAL (in template parsing)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}