2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 ********************************************************************
8 Derived from the official XSL DocBook Stylesheet distribution.
9 See http://nwalsh.com/docbook/xsl/ for copyright and other information.
11 This file contains localization templates (for internationalization)
12 ******************************************************************** -->
17 <xsl:param name=
"l10n.xml" select=
"document('../common/l10n.xml')"/>
18 <xsl:param name=
"l10n.gentext.language" select=
"''"/>
19 <xsl:param name=
"l10n.gentext.default.language" select=
"'en'"/>
20 <xsl:param name=
"l10n.gentext.use.xref.language" select=
"false()"/>
26 <xsl:template name=
"l10n.language">
27 <xsl:param name=
"target" select=
"."/>
28 <xsl:param name=
"xref-context" select=
"false()"/>
30 <xsl:variable name=
"language">
32 <xsl:when test=
"$l10n.gentext.language != ''">
33 <xsl:value-of select=
"$l10n.gentext.language"/>
36 <xsl:when test=
"$xref-context or $l10n.gentext.use.xref.language">
37 <xsl:variable name=
"lang-attr"
38 select=
"($target/ancestor-or-self::*/@lang
39 |$target/ancestor-or-self::*/@xml:lang)[last()]"/>
41 <xsl:when test=
"string($lang-attr) = ''">
42 <xsl:value-of select=
"$l10n.gentext.default.language"/>
45 <xsl:value-of select=
"$lang-attr"/>
51 <xsl:variable name=
"lang-attr"
52 select=
"(ancestor-or-self::*/@lang
53 |ancestor-or-self::*/@xml:lang)[last()]"/>
55 <xsl:when test=
"string($lang-attr) = ''">
56 <xsl:value-of select=
"$l10n.gentext.default.language"/>
59 <xsl:value-of select=
"$lang-attr"/>
67 <xsl:when test=
"contains($language,'-')">
68 <xsl:value-of select=
"substring-before($language,'-')"/>
69 <xsl:text>_
</xsl:text>
70 <xsl:value-of select=
"substring-after($language,'-')"/>
73 <xsl:value-of select=
"$language"/>
78 <xsl:template name=
"gentext.xref.text">
79 <xsl:param name=
"element.name" select=
"name(.)"/>
80 <xsl:param name=
"default"></xsl:param>
81 <xsl:param name=
"lang">
82 <xsl:call-template name=
"l10n.language"/>
85 <xsl:variable name=
"l10n.text">
86 <xsl:value-of select=
"($l10n.xml/internationalization/localization[@language=$lang]/xref[@element=$element.name])[1]/@text"/>
90 <xsl:when test=
"$l10n.text=''">
92 <xsl:when test=
"$default=''">
94 <xsl:text>No
"</xsl:text>
95 <xsl:value-of select="$lang
"/>
96 <xsl:text>" cross reference text for
"</xsl:text>
97 <xsl:value-of select="$element.name
"/>
98 <xsl:text>" exists and no default specified.
</xsl:text>
102 <xsl:value-of select=
"$default"/>
107 <xsl:value-of select=
"$l10n.text"/>
112 <xsl:template name=
"gentext">
113 <xsl:param name=
"key" select=
"local-name(.)"/>
114 <xsl:param name=
"lang">
115 <xsl:call-template name=
"l10n.language"/>
118 <xsl:variable name=
"l10n.gentext"
119 select=
"($l10n.xml/internationalization/localization[@language=$lang]/gentext[@key=$key])[1]"/>
121 <xsl:variable name=
"l10n.name">
122 <xsl:value-of select=
"$l10n.gentext/@text"/>
126 <xsl:when test=
"count($l10n.gentext)=0">
128 <xsl:text>No
"</xsl:text>
129 <xsl:value-of select="$lang
"/>
130 <xsl:text>" localization of
"</xsl:text>
131 <xsl:value-of select="$key
"/>
132 <xsl:text>" exists; using
"en".
</xsl:text>
135 <xsl:value-of select=
"($l10n.xml/internationalization/localization[@language='en']/gentext[@key=$key])[1]/@text"/>
138 <xsl:value-of select=
"$l10n.name"/>
143 <xsl:template name=
"gentext.element.name">
144 <xsl:param name=
"element.name" select=
"name(.)"/>
145 <xsl:param name=
"lang">
146 <xsl:call-template name=
"l10n.language"/>
149 <xsl:call-template name=
"gentext">
150 <xsl:with-param name=
"key" select=
"$element.name"/>
151 <xsl:with-param name=
"lang" select=
"$lang"/>
155 <xsl:template name=
"gentext.space">
156 <xsl:text> </xsl:text>
159 <xsl:template name=
"gentext.edited.by">
160 <xsl:call-template name=
"gentext.element.name">
161 <xsl:with-param name=
"element.name">Editedby
</xsl:with-param>
165 <xsl:template name=
"gentext.by">
166 <xsl:call-template name=
"gentext.element.name">
167 <xsl:with-param name=
"element.name">by
</xsl:with-param>
171 <xsl:template name=
"gentext.dingbat">
172 <xsl:param name=
"dingbat">bullet
</xsl:param>
173 <xsl:param name=
"lang">
174 <xsl:call-template name=
"l10n.language"/>
177 <xsl:variable name=
"l10n.dingbat">
178 <xsl:value-of select=
"($l10n.xml/internationalization/localization[@language=$lang]/dingbat[@key=$dingbat])[1]/@text"/>
182 <xsl:when test=
"$l10n.dingbat=''">
184 <xsl:text>No
"</xsl:text>
185 <xsl:value-of select="$lang
"/>
186 <xsl:text>" localization of dingbat
</xsl:text>
187 <xsl:value-of select=
"$dingbat"/>
188 <xsl:text> exists; using
"en".
</xsl:text>
191 <xsl:value-of select=
"($l10n.xml/internationalization/localization[@language='en']/dingbat[@key=$dingbat])[1]/@text"/>
194 <xsl:value-of select=
"$l10n.dingbat"/>
199 <xsl:template name=
"gentext.startquote">
200 <xsl:call-template name=
"gentext.dingbat">
201 <xsl:with-param name=
"dingbat">startquote
</xsl:with-param>
205 <xsl:template name=
"gentext.endquote">
206 <xsl:call-template name=
"gentext.dingbat">
207 <xsl:with-param name=
"dingbat">endquote
</xsl:with-param>
211 <xsl:template name=
"gentext.nestedstartquote">
212 <xsl:call-template name=
"gentext.dingbat">
213 <xsl:with-param name=
"dingbat">nestedstartquote
</xsl:with-param>
217 <xsl:template name=
"gentext.nestedendquote">
218 <xsl:call-template name=
"gentext.dingbat">
219 <xsl:with-param name=
"dingbat">nestedendquote
</xsl:with-param>
223 <xsl:template name=
"gentext.nav.prev">
224 <xsl:call-template name=
"gentext.element.name">
225 <xsl:with-param name=
"element.name">nav-prev
</xsl:with-param>
229 <xsl:template name=
"gentext.nav.next">
230 <xsl:call-template name=
"gentext.element.name">
231 <xsl:with-param name=
"element.name">nav-next
</xsl:with-param>
235 <xsl:template name=
"gentext.nav.home">
236 <xsl:call-template name=
"gentext.element.name">
237 <xsl:with-param name=
"element.name">nav-home
</xsl:with-param>
241 <xsl:template name=
"gentext.nav.up">
242 <xsl:call-template name=
"gentext.element.name">
243 <xsl:with-param name=
"element.name">nav-up
</xsl:with-param>