Skip to content

Commit

Permalink
Merge pull request #69 from wp-cli/36-core
Browse files Browse the repository at this point in the history
WordPress Core support
  • Loading branch information
schlessera authored Aug 6, 2018
2 parents f480758 + 61c7292 commit 7e36d97
Show file tree
Hide file tree
Showing 4 changed files with 740 additions and 133 deletions.
57 changes: 48 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ wp i18n

### wp i18n make-pot

Create a POT file for a WordPress plugin or theme.
Create a POT file for a WordPress project.

~~~
wp i18n make-pot <source> [<destination>] [--slug=<slug>] [--domain=<domain>] [--ignore-domain] [--merge[=<file>]] [--exclude=<paths>] [--skip-js]
wp i18n make-pot <source> [<destination>] [--slug=<slug>] [--domain=<domain>] [--ignore-domain] [--merge[=<paths>]] [--subtract=<paths>] [--include=<paths>] [--exclude=<paths>] [--headers=<headers>] [--skip-js] [--file-comment] [--package-name=<name>]
~~~

Scans PHP and JavaScript files, as well as theme stylesheets for translatable strings.
Scans PHP and JavaScript files for translatable strings, as well as theme stylesheets and plugin files
if the source directory is detected as either a plugin or theme.

**OPTIONS**

Expand All @@ -50,31 +51,69 @@ Scans PHP and JavaScript files, as well as theme stylesheets for translatable st
[--domain=<domain>]
Text domain to look for in the source code, unless the `--ignore-domain` option is used.
By default, the "Text Domain" header of the plugin or theme is used.
If none is provided, it falls back to the plugin/theme slug.
If none is provided, it falls back to the project slug.

[--ignore-domain]
Ignore the text domain completely and extract strings with any text domain.

[--merge[=<file>]]
Existing POT file file whose content should be merged with the extracted strings.
If left empty, defaults to the destination POT file.
[--merge[=<paths>]]
Comma-separated list of POT files whose contents should be merged with the extracted strings.
If left empty, defaults to the destination POT file. POT file headers will be ignored.

[--subtract=<paths>]
Comma-separated list of POT files whose contents should act as some sort of blacklist for string extraction.
Any string which is found on that blacklist will not be extracted.
This can be useful when you want to create multiple POT files from the same source directory with slightly
different content and no duplicate strings between them.

[--include=<paths>]
Comma-separated list of files and paths that should be used for string extraction.
If provided, only these files and folders will be taken into account for string extraction.
For example, `--include="src,my-file.php` will ignore anything besides `my-file.php` and files in the `src` directory.
Simple glob patterns can be used, i.e. `--include=foo-*.php` includes any PHP file with the `foo-` prefix.
Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.

[--exclude=<paths>]
Include additional ignored paths as CSV (e.g. 'tests,bin,.github').
By default, the following files and folders are ignored: node_modules, .git, .svn, .CVS, .hg, vendor.
Comma-separated list of files and paths that should be skipped for string extraction.
For example, `--exclude=".github,myfile.php` would ignore any strings found within `myfile.php` or the `.github` folder.
Simple glob patterns can be used, i.e. `--exclude=foo-*.php` excludes any PHP file with the `foo-` prefix.
Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.
The following files and folders are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.

[--headers=<headers>]
Array in JSON format of custom headers which will be added to the POT file. Defaults to empty array.

[--skip-js]
Skips JavaScript string extraction. Useful when this is done in another build step, e.g. through Babel.

[--file-comment]
String that should be added as a comment to the top of the resulting POT file.
By default, a copyright comment is added for WordPress plugins and themes in the following manner:

```
Copyright (C) 2018 Example Plugin Author
This file is distributed under the same license as the Example Plugin package.
```

If a plugin or theme specifies a license in their main plugin file or stylesheet, the comment looks like this:

```
Copyright (C) 2018 Example Plugin Author
This file is distributed under the GPLv2.
```

[--package-name=<name>]
Name to use for package name in the resulting POT file's `Project-Id-Version` header.
Overrides plugin or theme name, if applicable.

**EXAMPLES**

# Create a POT file for the WordPress plugin/theme in the current directory
$ wp i18n make-pot . languages/my-plugin.pot

# Create a POT file for the continents and cities list in WordPress core.
$ wp i18n make-pot . continents-and-cities.pot --include="wp-admin/includes/continents-cities.php" --ignore-domain

## Installing

This package is included with WP-CLI itself, no additional installation necessary.
Expand Down
Loading

0 comments on commit 7e36d97

Please sign in to comment.