codeql-action/node_modules/eslint-plugin-i18n-text
github-actions[bot] 0da815296a Update checked-in dependencies 2022-02-24 17:03:29 +00:00
..
rules Update checked-in dependencies 2021-08-11 13:02:43 +00:00
tests Update checked-in dependencies 2021-08-11 13:02:43 +00:00
.eslintrc Update checked-in dependencies 2021-08-11 13:02:43 +00:00
.prettierrc Update checked-in dependencies 2021-08-11 13:02:43 +00:00
.travis.yml Update checked-in dependencies 2021-08-11 13:02:43 +00:00
LICENSE Update checked-in dependencies 2021-08-11 13:02:43 +00:00
README.md Update checked-in dependencies 2021-08-11 13:02:43 +00:00
index.js Update checked-in dependencies 2021-08-11 13:02:43 +00:00
package.json Update checked-in dependencies 2022-02-24 17:03:29 +00:00

README.md

eslint-plugin-i18n-text

Disallow English text in string literals.

Embedding messages in JavaScript files prevents them from being translated into other languages. An alternative is to embed the translated text in the markup and find it with JavaScript.

<div class="js-message" data-success-message="It works!"></div>
const el = document.querySelector('.js-message')
el.textContent = el.getAttribute('data-success-message')

This pattern allows the web framework that's generating the markup to use its translation library to insert the appropriate translated text.

Installation

You'll first need to install ESLint:

$ npm install eslint --save-dev

Next, install eslint-plugin-i18n-text:

$ npm install eslint-plugin-i18n-text --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-i18n-text globally.

Usage

Add i18n-text to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": [
    "i18n-text"
  ],
  "rules": {
    "i18n-text/no-en": 2
  }
}

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.