servnest/DOCS/translation.md

39 lines
1.2 KiB
Markdown
Raw Normal View History

# Memo to work with gettext
## As a developer
Extract messages to be translated from the source files and into a Portable Object Template file:
2023-03-09 00:35:30 +00:00
```shell
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:
2023-03-09 00:35:30 +00:00
```shell
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
2023-03-09 00:35:30 +00:00
```shell
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
* any text editor
2023-03-09 00:35:30 +00:00
* dedicated translation software like [Poedit](https://poedit.net/), [KDE's Lokalize](https://apps.kde.org/lokalize/) or [GNOME Translation Editor](https://wiki.gnome.org/Apps/Gtranslator).
## As an administrator
To compile Portable Objects into Machine Objects:
2023-03-09 00:35:30 +00:00
```shell
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.