Lint HTML and template source files for hardcoded strings
Installing i18n-lint globally via npm gives you the i18n-lint
binary.
i18n-lint can be used in other projects as a library. After installing, simply require the module.
i18n-lint is also available as a grunt plugin: grunt-i18nlint.
i18n-lint
into a terminal.
require
the i18n-lint
lint module in your
code.
i18n-lint uses JavaScript functions to handle the output/processing of the errors collected by i18n-lint.
For example, here's a basic reporter which reports a count of hardcoded strings for each file which contained them:
This would produce output similar to:Name | Sample Output |
---|---|
default |
test/fixtures/1.html
2 | <h1>Hardcoded h1</h1>
^ Hardcoded <h1> tag
3 | <a href="#" alt="hardcoded alt"><%= translation %></a>
^ Hardcoded alt attribute
|
unix | |
json |
-h, --help
Display help text, then exit
-V, --version
Display version information, then exit
-a, --attributes <attributes>
Set which HTML attributes to check. Defaults to 'alt,title'
-i, --ignore-tags <tags>
Set which HTML elements should be ignored when searching for hardcoded strings. Defaults to 'style,script'
-t, --template-delimiters <delimiters>
Define the template delimiters that the input files use. For instance, templating languages with a Mustache-like
syntax should set this value to '{{,}}'
-r, --reporter <reporter>
Choose which report to output the results with. Defaults to 'default'
. JSHint reporters can also be used.
attributes
Set which HTML attributes to check. Defaults to ['alt', 'title']
ignoreTags
Set which HTML elements should be ignored when searching for hardcoded strings. Defaults to ['style', 'script']
templateDelimiters
Define the template delimiters that the input files use. For instance, templating languages with a Mustache-like
syntax should set this value to ['{{', '}}']
i18nlint
function returns an array containing objects which describe the error. Each object looks like this:
Code | Meaning |
---|---|
W001 | Element's text node content is a hardcoded string |
W002 | Element's attribute value is a hardcoded string |
Reporters can still be used when using i18n-lint as a library. Built-in reporters are stored in i18nlint.reporters
:
Licensed under the MIT license.
Please post a new issue on the project issue tracker.
To see all releases of the plugin, please visit the releases page on GitHub