1--- 2title: Notes for Translators 3category: Contributing 4layout: default 5SPDX-License-Identifier: LGPL-2.1-or-later 6--- 7 8# Notes for Translators 9 10systemd depends on the `gettext` package for multilingual support. 11 12You'll find the i18n files in the `po/` directory. 13 14The build system (meson/ninja) can be used to generate a template (`*.pot`), 15which can be used to create new translations. 16 17It can also merge the template into the existing translations (`*.po`), to pick 18up new strings in need of translation. 19 20Finally, it is able to compile the translations (to `*.gmo` files), so that 21they can be used by systemd software. (This step is also useful to confirm the 22syntax of the `*.po` files is correct.) 23 24## Creating a New Translation 25 26To create a translation to a language not yet available, start by creating the 27initial template: 28 29``` 30$ ninja -C build/ systemd-pot 31``` 32 33This will generate file `po/systemd.pot` in the source tree. 34 35Then simply copy it to a new `${lang_code}.po` file, where 36`${lang_code}` is the two-letter code for a language 37(possibly followed by a two-letter uppercase country code), according to the 38ISO 639 standard. 39 40In short: 41 42``` 43$ cp po/systemd.pot po/${lang_code}.po 44``` 45 46Then edit the new `po/${lang_code}.po` file (for example, 47using the `poedit` GUI editor.) 48 49## Updating an Existing Translation 50 51Start by updating the `*.po` files from the latest template: 52 53``` 54$ ninja -C build/ systemd-update-po 55``` 56 57This will touch all the `*.po` files, so you'll want to pay attention when 58creating a git commit from this change, to only include the one translation 59you're actually updating. 60 61Edit the `*.po` file, looking for empty translations and translations marked as 62"fuzzy" (which means the merger found a similar message that needs to be 63reviewed as it's expected not to match exactly.) 64 65You can use any text editor to update the `*.po` files, but a good choice is 66the `poedit` editor, a graphical application specifically designed for this 67purpose. 68 69Once you're done, create a git commit for the update of the `po/*.po` file you 70touched. Remember to undo the changes to the other `*.po` files (for instance, 71using `git checkout -- po/` after you commit the changes you do want to keep.) 72 73## Recompiling Translations 74 75You can recompile the `*.po` files using the following command: 76 77``` 78$ ninja -C build/ systemd-gmo 79``` 80 81The resulting files will be saved in the `build/po/` directory. 82