pressbooks / pressbooks-multi-institution

Tools for managing Pressbooks networks shared by multiple institutions
GNU General Public License v3.0
0 stars 1 forks source link

Localize plugin and prepare for French translation #33

Closed SteelWagstaff closed 8 months ago

SteelWagstaff commented 8 months ago

This plugin should be made ready for internationalization and localization, using our standard approach for open source plugins (i.e. Transifex automation).

DoD:

SteelWagstaff commented 8 months ago

I created a new file-based project in Transifex called Pressbooks Shared Network and assigned it to the Pressbooks team.

I also configured this plugin to be synced automatically with GitHub using these instructions: https://help.transifex.com/en/articles/6265125-github-installation-and-configuration

In order for the translations to be synced correctly, I had to create a valid transifex configuration .yaml file. See https://github.com/pressbooks/pressbooks-multi-institution/blob/dev/.tx/transifex.yaml.

I also configured Transifex to push content back to the repo whenever a language reached the 100% translation threshhold, via a PR with a specific chore(i10n): title Screenshot from 2024-02-19 15-15-38 Screenshot from 2024-02-19 15-15-17

SteelWagstaff commented 8 months ago

We could improve this by adding [ci skip] to the commit messages to avoid running our test suite and/or pushing translations directly to the project without a PR. We should also figure out a good way to generate and commit .mo files after .po files have been updated and before each release. These can be generated very simply with the WP CLI via this command: wp i18n make-mo languages

SteelWagstaff commented 8 months ago

We also need to correctly load this plugin's text domain: https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#div-comment-1568. In other plugins this is done in a hooks function in the main admin class: https://github.com/pressbooks/pressbooks-saml-sso/blob/78742aceeefd2d2d672e0c326dc92ee3d2fdcc6b/inc/class-admin.php#L32 or https://github.com/pressbooks/pressbooks-network-catalog/blob/e8ee46c68eb0b2c33a3568292787d0cf62ac2b80/src/PressbooksNetworkCatalog.php#L101-L102

SteelWagstaff commented 8 months ago

Plugin text domain is now being loaded correctly. Only remaining task is to figure out how to generate and add .mo files every time .po files are updated are in the project.

SteelWagstaff commented 8 months ago

@arzola I created this action: https://github.com/pressbooks/pressbooks-multi-institution/blob/dev/.github/workflows/update-mo.yml

It works, though I'm open to suggestions & improvements.

SteelWagstaff commented 8 months ago

We created a centralized action https://github.com/pressbooks/reusable-workflows/pull/7 for use by any plugin which needs .mo files to be generated. Pressbooks multi institution is now set up to use this action: https://github.com/pressbooks/pressbooks-multi-institution/pull/62

SteelWagstaff commented 8 months ago

To test this, we should generate new translation strings in Transifex. This should trigger an automatic PR in Pressbooks updating the .po files, which ought to automatically trigger the build and commit .mo file action.

SteelWagstaff commented 8 months ago

Tested, works as expected with some modifications. We can now use the reusable workflow in all relevant repos. See https://github.com/pressbooks/private/issues/1340

SteelWagstaff commented 8 months ago

Here's documentation for our team about how localization/translation works with Transifex: https://docs.google.com/document/d/1jsSkagdnO1TqaeGSztmxFqN1d6o-vIfgeZ7j7bSEo0Y/edit

Here's an old guide I wrote for translation contributors: https://docs.google.com/document/d/1jsSkagdnO1TqaeGSztmxFqN1d6o-vIfgeZ7j7bSEo0Y/edit

Here's a short video showing how a user can sign up for a Transifex account and begin contributing translations to a project: https://us02web.zoom.us/rec/share/g7_cAaiAMMvOFs0pZlX_x7-okI0sSfs9b6-ClgQTiW78TQTquANB_lumdH9_3FxS.2C3FHnAnDwAWwmIX Passcode: ^8tWT38C