{"id":16173362,"url":"https://github.com/jdgrimes/wp-l10n-validator","last_synced_at":"2025-03-19T00:30:49.454Z","repository":{"id":11668534,"uuid":"14177593","full_name":"JDGrimes/wp-l10n-validator","owner":"JDGrimes","description":"Gettext localization validator for WordPress","archived":false,"fork":false,"pushed_at":"2017-12-20T21:39:21.000Z","size":132,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-28T13:23:13.336Z","etag":null,"topics":["cli","gettext","i18n","l10n","php","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JDGrimes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-06T16:06:42.000Z","updated_at":"2020-02-15T08:49:33.000Z","dependencies_parsed_at":"2022-07-14T02:50:30.608Z","dependency_job_id":null,"html_url":"https://github.com/JDGrimes/wp-l10n-validator","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDGrimes%2Fwp-l10n-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDGrimes%2Fwp-l10n-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDGrimes%2Fwp-l10n-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDGrimes%2Fwp-l10n-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JDGrimes","download_url":"https://codeload.github.com/JDGrimes/wp-l10n-validator/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955805,"owners_count":20374373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","gettext","i18n","l10n","php","wordpress"],"created_at":"2024-10-10T04:08:30.855Z","updated_at":"2025-03-19T00:30:49.045Z","avatar_url":"https://github.com/JDGrimes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"WP L10n Validator [![Build Status](https://travis-ci.org/JDGrimes/wp-l10n-validator.png?branch=master)](https://travis-ci.org/JDGrimes/wp-l10n-validator)\n=================\n\nCommand-line tool for checking that all strings are properly gettexted for localization in WordPress plugins and themes.\n\n* Finds any untranslated strings in HTML\n* Finds any untranslated `'encapsed strings'` in PHP code\n* Makes sure all gettext function parameters are valid –no variables, function\n  calls, etc., where there should just be an encapsed string– and that all required\n  arguments are present.\n* Makes sure the expected textdomain(s) are always used\n* As a side effect, it also checks that no l10n functions are deprecated.\n\nInstallation\n------------\n\n**Requires:** PHP 5.3 or later.\n\nDownload a zip, clone the repo, or add to composer dependencies. Add the `/bin` directory to your `$PATH` (or use\n`/path/to/wp-l10n-validator/bin/wp-l10n-validator` instead of just `wp-l10n-validator`\nin your commands.\n\nTo see the basic usage and check that everything is working, type the command:\n\n`$ wp-l10n-validator`\n\nUsage\n-----\n\n`$ wp-l10n-validator -[1c] TEXTDOMAIN [CONFIG] [-- FILE ...]`\n\nThis validates all `.php` files in the current directory for proper gettexting.\n\nArguments:\n * `TEXTDOMAIN` - The textdomain used in your project.\n * `CONFIG` - Configuration to use. Corressponds to one of the directories in `/config` (`wordpress` by default).\n * `FILE` - One or more files to validate. You must pass `--` before the list of files, like this: `wp-l10n-validator textdomain -- a.php b.php`\n\nFlags:\n * `1` - Parse only one file at a time.\n * `c` - Generate a specific ignores cache. This is a JSON file that contains a list\n   of specific occurrences of strings to ignore. When you have fixed all of the real\n   problems with your project, there may be left many strings that do not need to be\n   gettexted. Running the command with this flag will cache all of those by file name\n   and line number, so that they will be ignored in future. This is especially useful\n   for strings that you want to ignore only in a specific location. If the line number\n   that a string is on changes, but by less than 5 lines, it will continue to be\n   ignored and the line number will be updated in the cache. You can change the number\n   of lines tolerance using the `ignores-tolerance` [configuration option](#configuration).\n\nThe validator will display any errors it finds.\n\nExample validating a plugin:\n\n```\n$ cd /path/to/my-plugin\n$ wp-l10n-validator my-plugin\n```\n\nYou can also add a `wp-l10n-validator.json` file in the main directory of your\nproject, which specifies the basic configuration for your project ([see below](#configuration)).\nWith this file in place you can run the parser without any arguments.\n\nConfiguration\n-------------\n\nThe validator can be configured specifically for your project as needed. Although it\ncan be completely customized, the main reason for additional configuration is to help\nthe parser weed out false positives. The strategy employed for weeding out most false\npositives is as follows:\n\n* Ignore non-translatable strings inside calls to certain functions\n* Ignore specific function arguments that don't need to be gettexted\n* Ignore certain HTML attributes' values\n* Ignore specific strings\n* Ignore specific string occurrences\n\nAll of these are configurable to match your particular project, though custom\nconfiguration is optional. To configure the parser, you can add a JSON file named\n`wp-l10n-validator.json` in the root directory of your project (or wherever you wish\nto run the parser from).\n\nThese are the options that you can specify in the the JSON config file:\n\n * `textdomain` - Your project's textdomain.\n * `basedir` - The main directory of your project (if different from the current directory).\n * `config` - The configuration to use ([see CLI arguments above](#usage)).\n * `cache` - The file to store the cache in. The default is `.wp-l10n-validator-cache.json`.\n * `ignores-cache` - The file to store the specific ignores cache in. The default is\n   `.wp-l10n-validator-ignores-cache.json`. See the `-c` flag above for more information.\n * `ignores-tolerance` - The number of lines of difference to allow for when checking\n   against the ignores cache. The default is 5.\n * `ignores-rules` - Configure which rules are used to determine if a string should be\n   ignored. It is an associative array with boolean values:\n   * `all-lowercase` — Ignore all strings that contain no uppercase characters. This\n     is a very useful rule to enable if you don't use any translatable strings that\n     are all lowercase. It is disabled by default to avoid false negatives. Add this\n     to your config to enable it:\n     ```json\n     \t\"ignores-rules\": {\n     \t\t\"all-lowercase\": true\n     \t},\n\t ```\n * `ignored-functions` - An associative array of functions to ignore. The value can be\n   an array of specific arguments to be ignored (by argument number), or simply `true`.\n   To ignore a class method, add it like this: `My_Class::my_method`. This will only\n   ignore the method when it is being called statically from outside the class like\n   `My_Class::my_method()`, or inside the class with `self::` or `$this-\u003e`. The parser\n   does not know what class is assigned to a variable, though it does know the\n   variable name. So you can ignore `$wpdb-\u003equery`, (which the parser does ignore by\n   default,) but adding `wpdb::query` will not match a call to `$wpdb-\u003equery()`. Adding\n   a class constructor (`My_Class::__construct`) will ignore `new My_Class()`. Calls\n   within a class to `parent::method()` will be mapped to the class that is specified\n   in the `extends` statement. If a method is being ignored in a parent class, it\n   will also be ignored in child classes as well. If a method is being ignored in an\n   interface, all classes that implement that interface will have that method ignored\n   as well (since 0.3.0).\n * `ignored-properties` - (0.3.0+) An associative array of class properties to ignore.\n   The values are currently just expected to be `true`. To ignore any strings in the\n   default value for a property, add it like this: `My_Class::$my_property`. This\n   will only ignore the declared value of the property, it will not ignore\n   assignments (yet). It is possible to ignore the default values for the property in\n   all classes that extend a particular parent class by using the parent class name:\n   `Parent_Class::$property`.\n * `ignored-strings` - An array of strings that should always be ignored.\n * `ignored-atts` - An array of HTML attributes to ignore.\n * `ignored-paths` - An array of file and folder paths to ignore. (Since 0.2.0)\n * `bootstrap` - A PHP file providing further, more advanced configuration. You can\n   even write your own child class to extend the validator. This allows you to change\n   the output method by overriding the `report_*` functions, for example. Just assign\n   and instance of your class to the `$parser` variable: `$parser = new My_L10n_Validator`.\n\nSee [example-config.json](example-config.json) for an example.\n\nNotes\n-----\n\n* Though written primarily as a CLI app, it may also be used directly from within\n  another script to validate a single file or a directory. Only the later option is\n  available from the default CLI usage.\n* Don't let the `WP` fool you. Though written primarily for WordPress, it can easily\n  be configured for other frameworks that use similar gettexting methods.\n\nCredits\n-------\n\n* [Codestyling Localization](http://wordpress.org/plugins/codestyling-localization/) for initial parser code.\n* [@nikola-tmw](https://github.com/nikolov-tmw) for pointing me in the right direction on wp-hackers.\n\nLicense\n-------\n\nDual licensed under GPLv2 and MIT licenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdgrimes%2Fwp-l10n-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdgrimes%2Fwp-l10n-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdgrimes%2Fwp-l10n-validator/lists"}