Adding new languages
Extend the toolkit’s generated text capabilities by adding new language files.
-
Copy this file to your plug-in.
- non-PDF output:
plugins/org.dita.base/xsl/common/strings.xml
- PDF output:
plugins/org.dita.pdf2/cfg/common/vars/strings.xml
- non-PDF output:
-
In your plug-in, edit
strings.xml
to contain references to the language files for which you are providing custom strings.<?xml version="1.0" encoding="UTF-8"?> <!-- Provide new languages for Gaelic and Vietnamese. --> <langlist> <lang xml:lang="ga" filename="strings-ga-ga.xml"/> <lang xml:lang="ga-GA" filename="strings-ga-ga.xml"/> <lang xml:lang="vi" filename="strings-vi-vn.xml"/> <lang xml:lang="vi-VN" filename="strings-vi-vn.xml"/> </langlist>
-
Copy this file to your plug-in into the same directory as step 1.
- non-PDF output:
plugins/org.dita.base/xsl/common/strings-en-us.xml
- PDF output:
plugins/org.dita.pdf2/cfg/common/vars/en.xml
- non-PDF output:
-
Rename the file to match the language you wish to add (for instance,
strings-vi-vn.xml
). -
Without changing the
@id
value, replace the generated text string for each variable.<variables> <variable id="Figure">Hình</variable> <variable id="Table">Bảng</variable> <variable id="Next topic">Chủ đề tiếp theo</variable> [...] <variable id="Copyright">Bản quyền</variable> <variable id="a11y.and-then"/> </variables>
-
Update your
plugin.xml
file to extend the strings available.<plugin id="com.example.your-plugin"> <feature extension="dita.xsl.strings" file="xsl/common/strings.xml"/> </plugin>
Your custom language strings are available to your stylesheets. For example, if processing in a context where the
@xml:lang
value isvi-VN
, the following call returns “Chủ đề tiếp theo” because it was defined as the text for the variable with@id
value ofNext topic
in step 5.<xsl:call-template name="getVariable"> <xsl:with-param name="id" select="'Next topic'"/> </xsl:call-template>
Related information