Development/Tutorials/Localization/Message Appearance

From KDE TechBase
Revision as of 03:33, 30 November 2013 by Lliehu (talk | contribs) (typo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Understanding How Messages Appear to Translators
Tutorial Series   Localization
Previous   Writing Applications With Localization in Mind
What's Next   n/a
Further Reading   n/a

Abstract

By reading the source code it can be hard to see how translators would see (or not see) the context of a message. This page is a short summary intended mostly for developers that lists the major points of what can be seen from the PO files and gives a few examples.

Introduction

Not all context information that can be seen or figured by reading the source code is extracted to the PO files. Because the amount and type of extracted information depends on from where and how the message is extracted, the rest of this page is divided into different sources of translatable messages.

The goal of this page is only to serve as an introduction and quick reference for this topic. For more information one can always look at the generated template (.pot) files, either by opening them in any text editor or with Lokalize. In KDE infrastructure they can be found in SVN under branches/stable/l10n-kde4/templates and trunk/l10n-kde4/templates.

Messages translated using i18n() and friends

For these messages the template files will only contain the following:

  • the source string (and plural form if i18np is used)
  • the context parameter if i18nc is used
  • the code comment beginning with "i18n:" if used
  • list of file names with row numbers for the locations the message appears in
  • the order in which the messages were extracted (sometimes useful, but not a replacement for other context information)

For example this message:

QString msg = i18nc("%1 and %2 are file names", "Do you want to replace %1 with %2?",
                    oldFile, newFile);

Appears like this in Lokalize:

If the message appears in many places, the context information from all the locations is shown.

Messages in .ui files

For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:

  • the type and name of the widget the message appears in
  • the name of the property the message is a value for

Examples:

For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translation should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is a good idea to additionally use "(qtdt-format)" as context as mentioned in Writing Applications With Localization in Mind.

Messages in .kcfg files

For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:

  • the tag the string is for
  • the name of the entry the tag is for
  • the name of the group the entry belongs to

For example: