{"id":19770,"library":"eslint-plugin-gettext","title":"eslint-plugin-gettext","description":"ESLint plugin providing linting rules for gettext internationalization API usage. Version 1.2.0 (latest stable) released in 2023. It enforces best practices such as preventing non-literal arguments in gettext calls and ensuring positional markers for multiple variables. Unlike generic i18n linting, this plugin targets gettext specifically, supporting both Jed and Django JS Catalog integrations. Designed for Node.js >=6.0.0, it requires ESLint as a peer dependency and is maintained by App Annie.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/appannie/eslint-plugin-gettext","tags":["javascript","gettext","gettext-eslint","literal","eslint","eslint-plugin","i18n","internationalization","localization"],"install":[{"cmd":"npm install eslint-plugin-gettext","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-gettext","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-gettext","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESLint automatically resolves the full package name; use the short form 'gettext' in plugins array.","wrong":"\"plugins\": [\"eslint-plugin-gettext\"]","symbol":"plugin reference in ESLint config","correct":"\"plugins\": [\"gettext\"]"},{"note":"Rule names must be prefixed with the plugin namespace in ESLint config.","wrong":"\"no-variable-string\": \"error\"","symbol":"no-variable-string rule","correct":"\"gettext/no-variable-string\": \"error\""},{"note":"The full rule name is required; no shorthand alias exists.","wrong":"\"gettext/require-positional-markers\": \"error\"","symbol":"required-positional-markers-for-multiple-variables rule","correct":"\"gettext/required-positional-markers-for-multiple-variables\": \"error\""}],"quickstart":{"code":"// .eslintrc.json\n{\n  \"plugins\": [\"gettext\"],\n  \"rules\": {\n    \"gettext/no-variable-string\": \"error\",\n    \"gettext/required-positional-markers-for-multiple-variables\": \"error\"\n  }\n}\n\n// Example file that will trigger errors:\ngettext(variable); // Error: no-variable-string\ngettext('%d cats %s dogs'); // Error: missing positional markers","lang":"javascript","description":"Configures ESLint with gettext plugin and enables two rules to catch invalid gettext calls."},"warnings":[{"fix":"Always use static string literals: gettext('static string').","message":"Rule no-variable-string rejects all non-literal arguments including computed strings like gettext('prefix' + suffix).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run 'npm install eslint --save-dev' alongside this plugin.","message":"The plugin requires ESLint as a peer dependency, not installed automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure strings with multiple variables use positional markers like %1$s %2$d.","message":"Rule required-positional-markers-for-multiple-variables only works with %d and %s placeholders; other placeholders may bypass the rule.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If using a different function name, manually alias or wrap calls.","message":"Plugin does not support custom gettext function names; only gettext, ngettext, pgettext, npgettext are checked.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install eslint-plugin-gettext --save-dev' and ensure node_modules is correct.","cause":"Plugin not installed or ESLint cannot resolve it.","error":"Error: Failed to load plugin 'gettext': Cannot find module 'eslint-plugin-gettext'"},{"fix":"Add 'plugins: [\"gettext\"]' to ESLint config and use the full rule name 'gettext/no-variable-string'.","cause":"Rule name is misspelled or plugin not loaded in config.","error":"Error: ESLint couldn't find the rule 'gettext/no-variable-string'"},{"fix":"Run 'npm install eslint-plugin-gettext --save-dev' and check peer dependency eslint.","cause":"Attempting to use plugin without installing it.","error":"Error: ESLint requires that plugins be installed separately: eslint-plugin-gettext"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}