Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: add info about textdomains to the package documentation #18070

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
$logo = new Jetpack_Logo();
```

### Package textdomains

Jetpack's packages use the 'jetpack' textdomain for translatable strings. Plugins that use these packages must change the textdomains in the packages when preparing the plugin for release. A few tools that can help automate this process are [node-wp-i18n](https://github.com/cedaro/node-wp-i18n) and [wp-textdomain](https://github.com/timelsass/wp-textdomain).

For example, a plugin could change the textdomain during the Composer `post-autoload-dump` event with the following script in the plugin's `composer.json` file:

`"post-autoload-dump": "node {path_to_script}/update_textdomain.js"`

where the `update_textdomain.js` file contains something like:

```
const wpTextdomain = require( 'wp-textdomain' );

wpTextdomain( './vendor/automattic/**/*.php', {
domain: 'plugin-textdomain',
fix: true,
glob: { follow: true },
} );
```

## Deploying packages

While the script we use to deploy the package takes care of everything, we might need to setup some stuff online in GitHub and Packagist. Let's use the Autoloader package as an example.
Expand All @@ -80,9 +100,11 @@ You may run unit tests locally for any given package by running `composer phpuni
via Jetpack Docker with the command `yarn docker:phpunit:package` for all package unit tests or
`yarn docker:phpunit:package packagename` for a specific one.

## Creating a New Package
## Developing Jetpack Packages

### Should my code be in a Package?
### Creating a New Package

#### Should my code be in a Package?

Not sure if your code should be in a Package? Here are some general guidelines we follow when deciding:

Expand All @@ -99,3 +121,7 @@ Not sure if your code should be in a Package? Here are some general guidelines w
### Package Autoloading

All new Jetpack package development should use classmap autoloading, which allows the class and file names to comply with the WordPress Coding Standards.

### Textdomains

Jetpack packages must use the 'jetpack' textdomain. The consuming plugin is responsible for updating the packages to use the plugin's textdomain.