Skip to content

Latest commit

 

History

History
46 lines (23 loc) · 1.85 KB

i18n.md

File metadata and controls

46 lines (23 loc) · 1.85 KB

i18n

A CLI command is provided to extract translations from twig files. It extends the core i18n make-pot command to include twig files.

bin/docker/wp i18n-twig make-pot

Note: This will include PHP files and JS files, so you shouldn't need to run the core version as well. Doing so, will overwrite the translations that include the twig files.

Translations

The easiest way to set up translations is to use the following scripts:

bin/makepot.sh - To make our project wide .pot file.

bin/pot2po.sh - To copy across our .pot file to .po files for each language. Only creates if non existing.

bin/po2mo.sh - Compiles the .po files into .mo files.

3rd party translations

We use wp-translations-downloader to manage 3rd party translations including core. To download translations for core WordPress and plugins, run:

bin/docker/composer wp-translation-downloader:download

I need to update translations

So you've added some new text and put it through __(). In order for it to work as a translation you will need to take the following steps:

  1. Run bin/makepot.sh - this will generate a fresh pot file which will contain your text

  2. Run git diff wp-content/languages/$PROJECT_NAME.pot on the new pot file

  3. Note what has changed

  4. Open up $PROJECT_NAME.pot and look for the changes you spotted in the diff

  5. Copy across manually to wp-content/languages/$PROJECT_NAME-en_GB.po and wp-content/languages/$PROJECT_NAME-cy.po

Try to keep them in the same location as they are in the pot file

  1. Update the translations spreadsheet manually with the stings you just copied across to the po files

  2. Once you have recieved the translations, update the po files accordingly

  3. Run bin/po2mo.sh to compile the strings and make them available to the site