Roles

In many cases, how to render an element depends on various conditions, such as the grammatical role. For these cases, the stylesheets allow translators to provide multiple translations, each marked with a role attribute from a fixed vocabulary. The list of valid roles will depend on the template, and should be given in the translator comment accompanying each string. However, there are a number of common cases, particularly for labels and cross references.

Translating using roles is similar to translating using plural forms. A translation consists of any number of msgstr elements, each with a role attribute. A msgstr element without an attribute can be provided as a default if none of the roles match.

For example, the citetitle element in DocBook is used to cite the title of a publication. The type of the publication is specified in the class attribute. In many English publications, article titles are placed in quotes, while book titles are italicized. The following fragment will quote article titles, but italicize all other cited titles.

<msgstr role='article'>“<node/>”</msgstr>
<msgstr><i><node/></i></msg:msgstr>

The Serbian translation team has chosen to follow the same convention of quoting article titles and italicizing all others. The entry in sr.po follows.

#: ../xslt/gettext/l10n.xml.in.h:304
msgid ""
"<msgid>citetitle.format</msgid> "
"<msgstr role='article'>“<node/>”</msgstr> "
"<msgstr><i><node/></i></msgstr>"
msgstr ""
"<msgstr role='article'>„<node/>“</msgstr>\n"
"<msgstr><i><node/></i></msgstr>"

The meaning of the markup inside the msgstr elements will be explained in Section 5.4 ― Format Strings. For now, simply note that multiple strings have been provided, each in a msgstr element. The only difference between the original string and the Serbian string is that Serbian is using a different opening quote character, aligned at the baseline.

Note also that the original translation contains an additional msgid element. This element is redundant in the merged XML; its only purpose is to distinguish the string from other strings, which may potentially have the same formatting in English. Redundant msgid elements are sometimes used even when neither plural forms nor roles are being used. In those cases, the sole translatable string is placed in a msgstr element with no attributes.