{"id":26658,"library":"wp-textdomain","title":"wp-textdomain","description":"A linting and fixing tool for WordPress plugin and theme textdomains in PHP files. Version 1.0.1 is latest. It scans PHP files using glob patterns and validates/replaces textdomain arguments in gettext functions like __, _e, _x, etc. Supports multiple domains in an array, automatic fixes (fix option), and custom keyword definitions. Key differentiators: specifically designed for WordPress, unlike general PHP linters; can fix missing or incorrect textdomains; configurable via options like engine (php-parser), variableDomain, and missingDomain.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/timelsass/wp-textdomain","tags":["javascript"],"install":[{"cmd":"npm install wp-textdomain","lang":"bash","label":"npm"},{"cmd":"yarn add wp-textdomain","lang":"bash","label":"yarn"},{"cmd":"pnpm add wp-textdomain","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Parses PHP files to analyze and modify gettext calls","package":"php-parser","optional":false},{"reason":"Matches file patterns to locate PHP files","package":"glob","optional":false},{"reason":"Formats timestamps for logfile configuration","package":"moment","optional":true}],"imports":[{"note":"Package exports a single function via CommonJS; ESM import is not supported by default","wrong":"import wpTextdomain from 'wp-textdomain';","symbol":"wpTextdomain","correct":"const wpTextdomain = require('wp-textdomain');"},{"note":"In TypeScript, if module resolution allows, you can use ESM but the package is CJS","wrong":"","symbol":"wpTextdomain","correct":"import wpTextdomain from 'wp-textdomain';"}],"quickstart":{"code":"const wpTextdomain = require('wp-textdomain');\n\n// Lint PHP files for textdomain 'my-theme'\nwpTextdomain('**/*.php', {\n  domain: 'my-theme',\n  fix: false\n});\n\n// With automatic fix using multiple domains\nwpTextdomain('**/*.php', {\n  domain: ['my-theme', 'kirki'],\n  fix: true\n});","lang":"javascript","description":"Shows basic linting and fixing of WordPress textdomains in PHP files using wp-textdomain."},"warnings":[{"fix":"Always ensure the primary domain is listed first in the domain array when fix:true.","message":"When using multiple domains, fixing uses the first domain as replacement; others are only valid.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Test with your codebase and consider reporting issues on GitHub.","message":"The package uses php-parser for parsing PHP; complex PHP syntax may cause errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using a custom date function or a lightweight alternative.","message":"The 'logfile' option with moment.js timestamp may be deprecated; moment is a heavy dependency.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure options object is provided with a 'domain' property (string or array).","cause":"Missing or incorrectly formatted options object, or domain not specified.","error":"Cannot read properties of undefined (reading 'domain')"},{"fix":"Double-check the pattern and working directory; use an absolute path if needed.","cause":"Provided glob pattern does not find any PHP files.","error":"No files matched for pattern: **/*.php"},{"fix":"Temporarily remove or fix the problematic PHP syntax, or update php-parser settings.","cause":"PHP file contains syntax that php-parser cannot parse.","error":"Error: php-parser: Parse Error on line X"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}