Format Strings

Using specialized format strings, the Gnome documentation stylesheets can translate more than just simple strings. These format strings are similar in principle to format strings used in C programs, except that XML is used to insert named parameters, rather than special format tokens being used to insert positional parameters.

For instance, DocBook provides the quote element, used to mark inline quotations. How to render an inline quotation depends on the typographic conventions of the language. In U.S. English, they are rendered inside “double inverted-comma” quotation marks. In Serbian, they are typically rendered with the opening quotation „aligned at the baseline“. The entry in the Serbian PO file for this format string follows.

#: ../xslt/gettext/l10n.xml.in.h:936
msgid ""
"<msgid>quote.format</msgid> "
"<msgstr role='inner'>‘<node/>’</msgstr> "
"<msgstr>“<node/>”</msgstr>"
msgstr ""
"<msgstr role='inner'>‘<node/>’</msgstr>\n"
"<msgstr>„<node/>”</msgstr>"

Multiple msgstr elements have been provided with roles. These are used to distinguish inner quotes from outer quotes. Roles were described in Section 5.3 ― Roles. The msgstr elements also contain inline markup. This markup is used to insert additional content. In this case, only the <node/> element has been used. This element is replaced by the contents of the quotation element being processed.

Each format string has a set number of named arguments available. These arguments should be documented in the translator comments that accompany the string. Note that the default translation may not make use of all the available arguments.

In addition to marker elements in format strings, translators may also use simple inline formatting markup. Any content can be wrapped in a span element with certain attributes to control formatting. The attributes are a subset of CSS properties. For HTML output, they are converted directly into the corresponding CSS. The list of allowed attributes is as follows:

font-family

This attribute sets the font family. Specifying exact font is generally a not advisable. Rather, this should be used to provide a generic family: serif, sans-serif, cursive, fantasy, or monospace.

font-style

This attribute can be used to italicize the text. The allowed values are italic, oblique, and normal.

font-variant

This attribute can be used to set the text in small caps. Small caps prints lowercase letters with smaller versions of the uppercase glyphs. The allowed values are small-caps and normal.

font-weight

This attribute can be used to mark the text bold. CSS allows any number from 100 to 900, with normal text being 400 and bold being 700. In addition to numerical values, you can use one of bold, bolder, lighter, or normal to use pre-defined values. Only bold and normal should generally be needed.

font-stretch

This attribute can be used to stretch or condense the font. CSS allows a number of keywords to specify by exactly how much to stretch the font. In practice, only wider, narrower, and normal should generally be used.

font-size

This attribute sets the size of the font. CSS allows both absolute font sizes using keywords or numeric lenghts, as well as relative font sizes using keywords or percentages. Generally, only larger, smaller, and normal should be used for this attribute. Better, use the big and small convenience elements described below. They are defined to respect the size scales used throughout the stylesheets.

text-decoration

This attribute can set various effects on the text. The allowed values are none, underline, overline, line-through, and blink. Don't use blink.

Additionally, extra inline elements are provided for convenience. The formatting done by these elements could also be done using the span element. Using these elements is just easier for common formatting tasks.

big

Make the text larger. This is preferred over using the font-size attribute, because it is defined to use the size scale used throughout the stylesheets.

small

Make the text smaller. This is preferred over using the font-size attribute, because it is defined to use the size scale used throughout the stylesheets.

sub

Render the text as a subscript.

sup

Render the text as a superscript.

b

Make the text bold. This is equivalent to setting the font-weight attribute to bold.

i

Make the text italic. This is equivalent to setting the font-style attribute to italic.

tt

Make the text monospace. This is equivalent to setting the font-family attribute to monospace.

u

Underline the text. This is equivalent to setting the text-decoration attribute to underline.