XML technologies / DocBook / The DocBook XSL stylesheets / Changing localization / Declaring the document language

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

The preferred way to specify a language is with the attribute lang in DocBook 4 or xml:lang in DocBook 5. This is usually added to the root element. The language then applies to all descendants unless overridden by xml:lang:

DocBook 4

<chapter lang="de">
    <title>...</title>
    <para>Ein deutscher Satz. ...</para>
    <para lang="en">An English sentence. ... </para>
</chapter>

DocBook 5

<chapter xml:lang="de">
    <title>...</title>
    <para>Ein deutscher Satz. ...</para>
    <para xml:lang="de">An English sentence. ... </para>
</chapter>

Although the chapter’s language is German, the second paragraph is within the scope of English. This can produce unwanted results. Consider the following example:

DocBook 4

<para lang="en">An English refence to <xref linkend="chap5"/>?</para> 

DocBook 5

<para xml:lang="en">An English refence to <xref linkend="chap5"/>?</para> 

Resolving the reference produces:

An English refence to Kapitel 5?

You may have intended the parent element’s language to apply to the xref element too. To achieve this, set the parameter l10n.gentext.use.xref.language to 1, and the reference appears as:

An English refence to Chapter 5?

  

back to top