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

🔧 Improve translation scripts #3013

Merged
merged 3 commits into from
Apr 7, 2022
Merged

🔧 Improve translation scripts #3013

merged 3 commits into from
Apr 7, 2022

Conversation

strarsis
Copy link
Contributor

@strarsis strarsis commented Mar 21, 2022

This PR adds more and improves existing translation related npm scripts:

npm scripts

  • translate: Run translate:pot and translate:update.
    This is used to update the PO files to the latest translatable strings in the theme.

    • translate:pot: Update the Poedit Template (POT) file from the theme files.
    • translate:update: Update PO translation files (for a specific locale, e.g. de_DE) from the Poedit Template (POT) file.
  • translate:compile: Run translate:js and translate:mo.
    This is used to compile all the PO files to JSON and MO for usage in PHP/JavaScript/WordPress.

    • translate:js: Generate the JavaScript JSON translation files from PO files, used by JavaScript related WordPress components like Gutenberg Blocks in the Gutenberg Editor.
    • translate:mo: Compile PO translation files to compiled, efficient MO files that are used by PHP/WordPress.

Workflow:

  • npm run translate to scan and update the PO translation files from the theme.
  • Open and update the PO translation files with a suitable program (usually PoEdit).
  • npm run translate:compile to compile the PO translation files to MO files that can be used by PHP/WordPress and to JavaScript JSON files that can be used by WordPress JavaScript (Gutenberg).
  • (Commit these translation-related changes).

WP CLI i18n supporting versions

WP CLI i18n has support for parsing out translation strings from Blade-PHP templates now.
A new version of wp-cli/i18n-command that contains the merged PR should be released in the near future.
In the meantime, installing wp-cli/i18n-command from the repository can be used to get PHP-Blade support:
When you have a i18n release newer than 2.2.13 and WP CLI release newer than 2.6.0 installed,
PHP-Blade support should be already included.
You can use wp i18n make-pot --help | grep blade and check whether blade is mentioned.

@retlehs
Copy link
Member

retlehs commented Mar 22, 2022

@strarsis i just wanted to say

  1. thank you for this PR
  2. thank you for the upstream work @ wp-cli/i18n-command

i'll circle back soon to review soon

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Member

@retlehs retlehs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. lets get npm run replaced with yarn
  2. https://docs.roots.io/sage/10.x/localization/ needs updating

strarsis and others added 2 commits April 6, 2022 20:46
Replace `npm` with `yarn`.

Co-authored-by: Ben Word <[email protected]>
Replace `npm` with `yarn`.

Co-authored-by: Ben Word <[email protected]>
@retlehs retlehs changed the title Add+improve translation scripts 🔧 Improve translation scripts Apr 7, 2022
@retlehs retlehs merged commit 828e570 into roots:main Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants