docs/back/translation.en.md

1.2 KiB

Memo to work with gettext

As a developer

Extract messages to be translated from the source files and into a Portable Object Template file:

xgettext --from-code=UTF-8 --no-wrap -d messages -p locales/ *.php */*.php */*/*.php
mv locales/messages.po locales/messages.pot

Merge messages into existing Portable Objects:

msgmerge --no-wrap locales/fr/C/LC_MESSAGES/messages.po locales/messages.pot -o locales/fr/C/LC_MESSAGES/messages.po

As a translator

To start a new translation

mkdir -p locales/fr/C/LC_MESSAGES/
msginit -i locales/messages.pot -o locales/fr/C/LC_MESSAGES/messages.po

To translate

Edit locales/fr/C/LC_MESSAGES/messages.po using either

As an administrator

To compile Portable Objects into Machine Objects:

msgfmt locales/fr/C/LC_MESSAGES/messages.po -o locales/fr/C/LC_MESSAGES/messages.mo

Machine Objects files are kept in cache by the PHP gettext extension, so PHP-FPM needs to be restarted to update translations.