Localization
DITA-OT supports more than 40 languages. The full list of supported languages (and their codes) is available here: https://www.dita-ot.org/dev/topics/globalization-languages.
- Set the
@xml:lang
attribute on the DITA maps and/or topics root element with one of the supported values (e.g.de
,fr-FR
,ru
,zh-CN
). - Set the
default.language
parameter in the transformation dialog box to the desired language code.
You can create language-dependent CSS rules in your customization CSS by adding rules using the
:lang
pseudo-class (see https://developer.mozilla.org/en-US/docs/Web/CSS/:lang).
How to Customize CSS Strings
*[class ~= "toc/title"][empty]:before {
content: "Agenda";
}
/* Title of the TOC page */
*[class ~= "toc/title"][empty]:lang(es):before {
content: "Contenidos";
}
p-i18n-xx.css
stylesheet, follow these instructions:- Copy one of the available stylesheets (located in the DITA-OT-DIR/plugins/com.oxygenxml.pdf.css/css/print/i18n directory) into your CSS
customization (other than the English one because it does not have the
:lang
pseudo-class since it is the default language). - For each rules, replace the
:lang(xx)
pseudo-class with your expected language code, then replace each property value with the expected label.
How to Modify Existing Strings
- DITA-OT-DIR/plugins/org.dita.base/xsl/common
- DITA-OT-DIR/plugins/org.dita.pdf2/cfg/common/vars
- DITA-OT-DIR/plugins/com.oxygenxml.pdf.css/resources/localization
To modify the generated text, you need to create a DITA-OT extension plugin that uses the dita.xsl.strings extension point. The following example uses English, but you can adapt it for any language:
- In the DITA-OT-DIR\plugins\ folder, create a folder for this plugin (for example, com.oxygenxml.pdf.css.localization).
- Create a plugin.xml file (in the folder you
created in step 1) that specifies the extension points, your parameter file, and your
customization stylesheet. For
example:
<plugin id="com.oxygenxml.pdf.css.localization"> <require plugin="com.oxygenxml.pdf.css"/> <feature extension="dita.xsl.strings" file="pdf-extension-strings.xml"/> </plugin>
- Create a pdf-extension-strings.xml file with the
following content:
<langlist> <lang xml:lang="en" filename="strings-en-us.xml"/> <lang xml:lang="en-us" filename="strings-en-us.xml"/> </langlist>
- Copy the strings you want to change from the default files to the
strings-en-us.xml file, then replace their values:
<strings xml:lang="en-US"> <str name="Figure">Fig</str> <str name="Table">Array</str> </strings>
Warning:Make sure the string@name
attribute remains the same, it is used by the process as a key to retrieve the strings text. - Use the Integrate/Install DITA-OT Plugins transformation scenario found in the DITA Map section in the Configure Transformation Scenario(s) dialog box.
- Run the DITA Map PDF - based on HTML5 & CSS transformation scenario.
How to Add New Strings
Some strings are not translated in all languages. In this case, they will appear in English. To add a new language for a given string, you need to create a DITA-OT extension plugin that uses the dita.xsl.strings extension point. The following example uses Polish, but you can adapt it for any language:
- In the DITA-OT-DIR\plugins\ folder, create a folder for this plugin (for example, com.oxygenxml.pdf.css.localization).
- Create a plugin.xml file (in the folder you
created in step 1) that specifies the extension points, your parameter file, and your
customization stylesheet. For
example:
<plugin id="com.oxygenxml.pdf.css.localization"> <require plugin="com.oxygenxml.pdf.css"/> <feature extension="dita.xsl.strings" file="pdf-extension-strings.xml"/> </plugin>
- Create a pdf-extension-strings.xml file with the
following content:
<langlist> <lang xml:lang="pl" filename="strings-pl-pl.xml"/> <lang xml:lang="pl-pl" filename="strings-pl-pl.xml"/> </langlist>
- Copy the strings you want to change from the default files to the
strings-pl-pl.xml file, then replace their values:
<strings xml:lang="pl-PL"> <str name="Continued">(ciąg dalszy)</str> </strings>
Warning:Make sure the string@name
attribute remains the same, it is used by the process as a key to retrieve the strings text. - Use the Integrate/Install DITA-OT Plugins transformation scenario found in the DITA Map section in the Configure Transformation Scenario(s) dialog box.
- Run the DITA Map PDF - based on HTML5 & CSS transformation scenario.