12.3. Editing translation files#

The actual translation process is done by editing translation files which are named <lang>.po, where <lang> is an ISO-639-1 language code. For example, the German code is de, which results in de.po filenames. When following the instructions in the preceding sections, these files are generated by the package gettext behind the scenes. The manual can be found in GNU gettext utilities.

12.3.1. Editing translation entries#

In the following listing shows a simple example of a translation file:

#: umc/app.js:637
#, python-format
msgid "The %s will expire in %d days and should be renewed!"
msgstr ""
  • The first line provides a hint, were the text is used.

  • The second line is optional and contains flags, which indicate the type and state of the translation.

  • The line starting with msgid contains the original text. The translation has to be placed on the line containing msgstr.

For more information about the PO file format, for example about the flags, see The Format of PO Files.

Long texts can be split over multiple lines, were each line must start and end with a double-quote. The following example from the German translation shows a text spanning two lines, with the placeholder present in the original and translated text:

#: umc/js/appcenter/AppCenterPage.js:1067
#, python-format
msgid ""
"If everything else went correct and this is just a temporary network "
"problem, you should execute %s as root on that backup system."
msgstr ""
"Wenn keine weiteren Fehler auftraten und dies nur ein temporäres "
"Netzwerkproblem ist, sollten Sie %s als root auf dem Backup System ausführen."

Some lines contain parameters, in this example %s and %d. They are indicated by a flag like c-format or python-format, which must not be removed. The placeholders have to be carried over to the translated string unmodified and in the same order. Some other files contain placeholders of the form %(text)s, which are more flexible and can be reordered. Because of that, programmers should always use the form %(foo)s.

After a file has been translated completely, the line containing fuzzy at the beginning of the entry must be removed to avoid warnings. If a translation string consists of multiple lines the translated string should roughly contain as many lines as the original string.

When a msgid has changed and a translation existed beforehand, it is marked with “#, fuzzy”, as those have to be corrected:

#: umc/js/appcenter/example.js:42
#, fuzzy
msgid "Hello!"
msgstr "Hallo, Welt!"

Correct the translation in the msgstr line and remove the line which contains fuzzy:

#: umc/js/appcenter/example.js:42
msgid "Hello!"
msgstr "Hallo!"

Warning

If a fuzzy entry is still in one of the de.po files, the package build process fails.

12.3.2. Update meta information#

The first entry of a .po file contains its meta information, with each line consisting of a name-value pair. If the translation work within a file is done, update this information. As an example, see the following excerpt from a .po translation file:

msgid ""
msgstr ""
"Project-Id-Version: univention-management-console-module-services\n"
"Report-Msgid-Bugs-To: packages@univention.de\n"
"POT-Creation-Date: 2020-09-25 01:15+0200\n"
"PO-Revision-Date: 2020-09-25 11:26+0100\n"
"Last-Translator: Univention GmbH <packages@univention.de>\n"
"Language-Team: Univention GmbH <packages@univention.de>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

Running univention-l10n-build updates the POT-Creation-Date. The PO-Revision-Date should be updated every time the .po has been modified. Insert the ISO 639 language code for the target translation language into Language. Enter contact information into Last-Translator, Language-Team and Report-Msgid-Bugs-To.

See the gettext manual entry about header entries for more information about all fields, including optional fields not listed here. Tools like poedit update some of the fields automatically for the user.