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

I18N Package: Improve documentation / deprecate tools #12502

Closed
swissspidy opened this issue Dec 1, 2018 · 4 comments
Closed

I18N Package: Improve documentation / deprecate tools #12502

swissspidy opened this issue Dec 1, 2018 · 4 comments
Assignees
Labels
[Package] i18n /packages/i18n [Type] Developer Documentation Documentation for developers

Comments

@swissspidy
Copy link
Member

swissspidy commented Dec 1, 2018

The i18n package's readme currently says:

Note that you will not need to specify domain for the strings.

This might be true if you do the string extraction yourself, but it sets false expectations for developers trying to use the package.

I suggest replacing this paragraph with an information that the text domain should match the plugin slug.

I've written a lengthy blog post about the importance of the text domain in WordPress internationalization here: https://pascalbirchler.com/text-domain-wordpress-internationalization/

Also, there's this part:

This is useful to trick WordPress.org translation strings discovery since at the moment, WordPress.org is not capable of parsing strings directly from JavaScript files.

Which is totally out of date now. See https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/

@swissspidy swissspidy added [Type] Developer Documentation Documentation for developers [Package] i18n /packages/i18n labels Dec 1, 2018
@swissspidy swissspidy self-assigned this Dec 1, 2018
@swissspidy swissspidy changed the title I18N Package: Remove misleading documentation I18N Package: Improve documentation / deprecate tools Dec 1, 2018
@swissspidy
Copy link
Member Author

Another important thing:

The WordPress i18n Babel plugin can be used to generate a .pot file containing all your localized strings.

The only legit use case for this is when you aren't developing a WordPress plugin/theme, but something entirely out of WordPress.

If you're developing a WordPress plugin hosted on WordPress.org, there's no need for either the Babel plugin or pot-to-php. This is all done automatically by the WordPress.org infrastructure. See https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/

If you're developing a private WordPress plugin, you'll want to extract all strings of your project — PHP and JavaScript.

For this, the Babel plugin and pot-to-php are less than ideal because it basically duplicates your work:

  1. You generate a POT file using Babel
  2. You generate a PHP file with these strings using pot-to-php
  3. You generate a new POT file from your PHP strings using wp i18n make-pot.

Not only does it duplicate your work, it also is pretty pointless because the WP-CLI command scans JavaScript files just fine.

If you use pot-to-php, however, you will loose important context. Your POT file from step 3 will add references to the generated PHP file instead of the actual JavaScript files. This is bad for translators.

My suggestion:

  1. Remove pot-to-php and don't advertise it anywhere anymore.
  2. Explain differences between non-WordPress projects, WordPress.org-hosted plugins/themes and private plugins/themes
  3. Encourage people to use WP-CLI for creating POT and JSON translation files

@simison
Copy link
Member

simison commented Feb 4, 2019

Note that you will not need to specify domain for the strings

Also brought up in #13132

@bobbingwide
Copy link
Contributor

bobbingwide commented Apr 5, 2019

During WordCamp London contributor day I was looking at the process to internationalize my own plugin and @swissspidy said the docs were out of date. Rather than use po2json developers should use wp i18n make-json. No time to work on it today as I have to fill goody bags for tomorrow.

@swissspidy swissspidy reopened this Apr 5, 2019
@youknowriad
Copy link
Contributor

This seems fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] i18n /packages/i18n [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

No branches or pull requests

4 participants