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

Proper way to generate translations #14780

Closed
HardeepAsrani opened this issue Apr 2, 2019 · 2 comments
Closed

Proper way to generate translations #14780

HardeepAsrani opened this issue Apr 2, 2019 · 2 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@HardeepAsrani
Copy link
Contributor

What will the proper way translate your plugin using? https://www.npmjs.com/package/@wordpress/babel-plugin-makepot

Keep that in mind that we have PHP files that have some strings + JS files. Can we have two separate POT files and GlotPress work properly?

Or is there a way to use the same babel plugin to translate pot from JS/PHP?

@youknowriad
Copy link
Contributor

I think this plugin is not needed anymore. This page https://wordpress.org/gutenberg/handbook/designers-developers/developers/internationalization/ details how i18n work.

ping @swissspidy for more info here.

@youknowriad youknowriad added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Apr 3, 2019
@swissspidy
Copy link
Member

Yep, the link provided by Riad should give you all the information you need.

You can still use the Babel makepot plugin, and use it in combination with WP-CLI. But in theory just using WP-CLI alone for this would work as well.

Basically it works like this:

  1. Run wp i18n make-pot to generate 1 POT file for all your PHP and JS strings.
  2. Translate your project (which leads to creation of PO files)
  3. Run wp i18n make-json to split up the PO files into JSON translation files for use with Gutenberg, leaving the PO files themselves to be for the PHP strings only

If you still want to use the Babel makepot plugin for some reason, it would be a bit different:

  1. Build your JS (including the Babel plugin that creates a POT file)
  2. Run wp i18n make-pot --skip-js --merge=path/to/generated-by-babel-plugin.pot to get a single POT file containing all the translations again
  3. Same procedure as before with wp i18n make-json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants