l10n.xsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
  4. exclude-result-prefixes="l"
  5. version='1.0'>
  6. <!-- ********************************************************************
  7. $Id: l10n.xsl 9708 2013-01-22 13:41:24Z kosek $
  8. ********************************************************************
  9. This file is part of the XSL DocBook Stylesheet distribution.
  10. See ../README or http://docbook.sf.net/release/xsl/current/ for
  11. copyright and other information.
  12. This file contains localization templates (for internationalization)
  13. ******************************************************************** -->
  14. <xsl:param name="l10n.xml" select="document('../common/l10n.xml')"/>
  15. <xsl:param name="local.l10n.xml" select="document('')"/>
  16. <xsl:param name="empty.local.l10n.xml" select="not($local.l10n.xml//l:l10n)"/>
  17. <xsl:key name="l10n-lang" match="l:l10n" use="@language"/>
  18. <xsl:key name="l10n-gentext" match="l:l10n/l:gentext" use="@key"/>
  19. <xsl:key name="l10n-dingbat" match="l:l10n/l:dingbat" use="@key"/>
  20. <xsl:key name="l10n-context" match="l:l10n/l:context" use="@name"/>
  21. <xsl:key name="l10n-template" match="l:l10n/l:context/l:template[not(@style)]" use="concat(../@name, '#', @name)"/>
  22. <xsl:key name="l10n-template-style" match="l:l10n/l:context/l:template[@style]" use="concat(../@name, '#', @name, '#', @style)"/>
  23. <xsl:template name="l10n.language">
  24. <xsl:param name="target" select="."/>
  25. <xsl:param name="xref-context" select="false()"/>
  26. <xsl:variable name="mc-language">
  27. <xsl:choose>
  28. <xsl:when test="$l10n.gentext.language != ''">
  29. <xsl:value-of select="$l10n.gentext.language"/>
  30. </xsl:when>
  31. <xsl:when test="$xref-context or $l10n.gentext.use.xref.language != 0">
  32. <!-- can't do this one step: attributes are unordered! -->
  33. <xsl:variable name="lang-scope"
  34. select="$target/ancestor-or-self::*
  35. [@lang or @xml:lang][1]"/>
  36. <xsl:variable name="lang-attr"
  37. select="($lang-scope/@lang | $lang-scope/@xml:lang)[1]"/>
  38. <xsl:choose>
  39. <xsl:when test="string($lang-attr) = ''">
  40. <xsl:value-of select="$l10n.gentext.default.language"/>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:value-of select="$lang-attr"/>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <!-- can't do this one step: attributes are unordered! -->
  49. <xsl:variable name="lang-scope"
  50. select="$target/ancestor-or-self::*
  51. [@lang or @xml:lang][1]"/>
  52. <xsl:variable name="lang-attr"
  53. select="($lang-scope/@lang | $lang-scope/@xml:lang)[1]"/>
  54. <xsl:choose>
  55. <xsl:when test="string($lang-attr) = ''">
  56. <xsl:value-of select="$l10n.gentext.default.language"/>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <xsl:value-of select="$lang-attr"/>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:variable>
  65. <xsl:variable name="language" select="translate($mc-language,
  66. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-',
  67. 'abcdefghijklmnopqrstuvwxyz_')"/>
  68. <xsl:for-each select="$l10n.xml"> <!-- We need to change context in order to get key work -->
  69. <xsl:choose>
  70. <xsl:when test="key('l10n-lang', $language)">
  71. <xsl:value-of select="$language"/>
  72. </xsl:when>
  73. <!-- try just the lang code without country -->
  74. <xsl:when test="key('l10n-lang', substring-before($language,'_'))">
  75. <xsl:value-of select="substring-before($language,'_')"/>
  76. </xsl:when>
  77. <!-- or use the default -->
  78. <xsl:otherwise>
  79. <xsl:message>
  80. <xsl:text>No localization exists for "</xsl:text>
  81. <xsl:value-of select="$language"/>
  82. <xsl:text>" or "</xsl:text>
  83. <xsl:value-of select="substring-before($language,'_')"/>
  84. <xsl:text>". Using default "</xsl:text>
  85. <xsl:value-of select="$l10n.gentext.default.language"/>
  86. <xsl:text>".</xsl:text>
  87. </xsl:message>
  88. <xsl:value-of select="$l10n.gentext.default.language"/>
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:for-each>
  92. </xsl:template>
  93. <xsl:template name="l10n.language.name">
  94. <xsl:param name="lang">
  95. <xsl:call-template name="l10n.language"/>
  96. </xsl:param>
  97. <xsl:for-each select="$l10n.xml">
  98. <xsl:value-of
  99. select="document(key('l10n-lang', $lang)/@href)/l:l10n/@english-language-name"/>
  100. </xsl:for-each>
  101. </xsl:template>
  102. <xsl:template name="language.attribute">
  103. <xsl:param name="node" select="."/>
  104. <xsl:variable name="language">
  105. <xsl:choose>
  106. <xsl:when test="$l10n.gentext.language != ''">
  107. <xsl:value-of select="$l10n.gentext.language"/>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <!-- can't do this one step: attributes are unordered! -->
  111. <xsl:variable name="lang-scope"
  112. select="$node/ancestor-or-self::*
  113. [@lang or @xml:lang][1]"/>
  114. <xsl:variable name="lang-attr"
  115. select="($lang-scope/@lang | $lang-scope/@xml:lang)[1]"/>
  116. <xsl:choose>
  117. <xsl:when test="string($lang-attr) = ''">
  118. <xsl:value-of select="$l10n.gentext.default.language"/>
  119. </xsl:when>
  120. <xsl:otherwise>
  121. <xsl:value-of select="$lang-attr"/>
  122. </xsl:otherwise>
  123. </xsl:choose>
  124. </xsl:otherwise>
  125. </xsl:choose>
  126. </xsl:variable>
  127. <xsl:if test="$language != ''">
  128. <xsl:attribute name="lang">
  129. <xsl:choose>
  130. <xsl:when test="$l10n.lang.value.rfc.compliant != 0">
  131. <xsl:value-of select="translate($language, '_', '-')"/>
  132. </xsl:when>
  133. <xsl:otherwise>
  134. <xsl:value-of select="$language"/>
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:attribute>
  138. </xsl:if>
  139. <!-- FIXME: This is sort of hack, but it was the easiest way to add at least partial support for dir attribute -->
  140. <xsl:copy-of select="ancestor-or-self::*[@dir][1]/@dir"/>
  141. </xsl:template>
  142. <!-- Duplication of language.attribute template to allow for xml:lang attribute
  143. creation for XHTML 1.1 and epub target -->
  144. <xsl:template name="xml.language.attribute">
  145. <xsl:param name="node" select="."/>
  146. <xsl:variable name="language">
  147. <xsl:choose>
  148. <xsl:when test="$l10n.gentext.language != ''">
  149. <xsl:value-of select="$l10n.gentext.language"/>
  150. </xsl:when>
  151. <xsl:otherwise>
  152. <!-- can't do this one step: attributes are unordered! -->
  153. <xsl:variable name="lang-scope"
  154. select="$node/ancestor-or-self::*
  155. [@lang or @xml:lang][1]"/>
  156. <xsl:variable name="lang-attr"
  157. select="($lang-scope/@lang | $lang-scope/@xml:lang)[1]"/>
  158. <xsl:choose>
  159. <xsl:when test="string($lang-attr) = ''">
  160. <xsl:value-of select="$l10n.gentext.default.language"/>
  161. </xsl:when>
  162. <xsl:otherwise>
  163. <xsl:value-of select="$lang-attr"/>
  164. </xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:otherwise>
  167. </xsl:choose>
  168. </xsl:variable>
  169. <xsl:if test="$language != ''">
  170. <xsl:attribute name="xml:lang">
  171. <xsl:choose>
  172. <xsl:when test="$l10n.lang.value.rfc.compliant != 0">
  173. <xsl:value-of select="translate($language, '_', '-')"/>
  174. </xsl:when>
  175. <xsl:otherwise>
  176. <xsl:value-of select="$language"/>
  177. </xsl:otherwise>
  178. </xsl:choose>
  179. </xsl:attribute>
  180. </xsl:if>
  181. <!-- FIXME: This is sort of hack, but it was the easiest way to add at least partial support for dir attribute -->
  182. <xsl:copy-of select="ancestor-or-self::*[@dir][1]/@dir"/>
  183. </xsl:template>
  184. <xsl:template name="gentext">
  185. <xsl:param name="key" select="local-name(.)"/>
  186. <xsl:param name="lang">
  187. <xsl:call-template name="l10n.language"/>
  188. </xsl:param>
  189. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  190. <xsl:for-each select="document(key('l10n-lang', $lang)/@href)">
  191. <xsl:variable name="local.l10n.gentext"
  192. select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:gentext[@key=$key])[1]"/>
  193. <xsl:variable name="l10n.gentext"
  194. select="key('l10n-gentext', $key)[1]"/>
  195. <xsl:choose>
  196. <xsl:when test="$local.l10n.gentext">
  197. <xsl:value-of select="$local.l10n.gentext/@text"/>
  198. </xsl:when>
  199. <xsl:when test="$l10n.gentext">
  200. <xsl:value-of select="$l10n.gentext/@text"/>
  201. </xsl:when>
  202. <xsl:otherwise>
  203. <xsl:message>
  204. <xsl:text>No "</xsl:text>
  205. <xsl:value-of select="$lang"/>
  206. <xsl:text>" localization of "</xsl:text>
  207. <xsl:value-of select="$key"/>
  208. <xsl:text>" exists</xsl:text>
  209. <xsl:choose>
  210. <xsl:when test="$lang = 'en'">
  211. <xsl:text>.</xsl:text>
  212. </xsl:when>
  213. <xsl:otherwise>
  214. <xsl:text>; using "en".</xsl:text>
  215. </xsl:otherwise>
  216. </xsl:choose>
  217. </xsl:message>
  218. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  219. <xsl:for-each select="document(key('l10n-lang', 'en')/@href)">
  220. <xsl:value-of select="key('l10n-gentext', $key)[1]/@text"/>
  221. </xsl:for-each>
  222. </xsl:for-each>
  223. </xsl:otherwise>
  224. </xsl:choose>
  225. </xsl:for-each>
  226. </xsl:for-each>
  227. </xsl:template>
  228. <xsl:template name="gentext.element.name">
  229. <xsl:param name="element.name" select="local-name(.)"/>
  230. <xsl:param name="lang">
  231. <xsl:call-template name="l10n.language"/>
  232. </xsl:param>
  233. <xsl:call-template name="gentext">
  234. <xsl:with-param name="key" select="$element.name"/>
  235. <xsl:with-param name="lang" select="$lang"/>
  236. </xsl:call-template>
  237. </xsl:template>
  238. <xsl:template name="gentext.space">
  239. <xsl:text> </xsl:text>
  240. </xsl:template>
  241. <xsl:template name="gentext.edited.by">
  242. <xsl:call-template name="gentext">
  243. <xsl:with-param name="key" select="'Editedby'"/>
  244. </xsl:call-template>
  245. </xsl:template>
  246. <xsl:template name="gentext.by">
  247. <xsl:call-template name="gentext">
  248. <xsl:with-param name="key" select="'by'"/>
  249. </xsl:call-template>
  250. </xsl:template>
  251. <xsl:template name="gentext.dingbat">
  252. <xsl:param name="dingbat">bullet</xsl:param>
  253. <xsl:param name="lang">
  254. <xsl:call-template name="l10n.language"/>
  255. </xsl:param>
  256. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  257. <xsl:for-each select="document(key('l10n-lang', $lang)/@href)">
  258. <xsl:variable name="local.l10n.dingbat"
  259. select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:dingbat[@key=$dingbat])[1]"/>
  260. <xsl:variable name="l10n.dingbat"
  261. select="key('l10n-dingbat', $dingbat)[1]"/>
  262. <xsl:choose>
  263. <xsl:when test="$local.l10n.dingbat">
  264. <xsl:value-of select="$local.l10n.dingbat/@text"/>
  265. </xsl:when>
  266. <xsl:when test="$l10n.dingbat">
  267. <xsl:value-of select="$l10n.dingbat/@text"/>
  268. </xsl:when>
  269. <xsl:otherwise>
  270. <xsl:message>
  271. <xsl:text>No "</xsl:text>
  272. <xsl:value-of select="$lang"/>
  273. <xsl:text>" localization of dingbat </xsl:text>
  274. <xsl:value-of select="$dingbat"/>
  275. <xsl:text> exists; using "en".</xsl:text>
  276. </xsl:message>
  277. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  278. <xsl:for-each select="document(key('l10n-lang', 'en')/@href)">
  279. <xsl:value-of select="key('l10n-dingbat', $dingbat)[1]/@text"/>
  280. </xsl:for-each>
  281. </xsl:for-each>
  282. </xsl:otherwise>
  283. </xsl:choose>
  284. </xsl:for-each>
  285. </xsl:for-each>
  286. </xsl:template>
  287. <xsl:template name="gentext.startquote">
  288. <xsl:call-template name="gentext.dingbat">
  289. <xsl:with-param name="dingbat">startquote</xsl:with-param>
  290. </xsl:call-template>
  291. </xsl:template>
  292. <xsl:template name="gentext.endquote">
  293. <xsl:call-template name="gentext.dingbat">
  294. <xsl:with-param name="dingbat">endquote</xsl:with-param>
  295. </xsl:call-template>
  296. </xsl:template>
  297. <xsl:template name="gentext.nestedstartquote">
  298. <xsl:call-template name="gentext.dingbat">
  299. <xsl:with-param name="dingbat">nestedstartquote</xsl:with-param>
  300. </xsl:call-template>
  301. </xsl:template>
  302. <xsl:template name="gentext.nestedendquote">
  303. <xsl:call-template name="gentext.dingbat">
  304. <xsl:with-param name="dingbat">nestedendquote</xsl:with-param>
  305. </xsl:call-template>
  306. </xsl:template>
  307. <xsl:template name="gentext.nav.prev">
  308. <xsl:call-template name="gentext">
  309. <xsl:with-param name="key" select="'nav-prev'"/>
  310. </xsl:call-template>
  311. </xsl:template>
  312. <xsl:template name="gentext.nav.next">
  313. <xsl:call-template name="gentext">
  314. <xsl:with-param name="key" select="'nav-next'"/>
  315. </xsl:call-template>
  316. </xsl:template>
  317. <xsl:template name="gentext.nav.home">
  318. <xsl:call-template name="gentext">
  319. <xsl:with-param name="key" select="'nav-home'"/>
  320. </xsl:call-template>
  321. </xsl:template>
  322. <xsl:template name="gentext.nav.up">
  323. <xsl:call-template name="gentext">
  324. <xsl:with-param name="key" select="'nav-up'"/>
  325. </xsl:call-template>
  326. </xsl:template>
  327. <!-- ============================================================ -->
  328. <xsl:template name="gentext.template">
  329. <xsl:param name="context" select="'default'"/>
  330. <xsl:param name="name" select="'default'"/>
  331. <xsl:param name="origname" select="$name"/>
  332. <xsl:param name="purpose"/>
  333. <xsl:param name="xrefstyle"/>
  334. <xsl:param name="referrer"/>
  335. <xsl:param name="lang">
  336. <xsl:call-template name="l10n.language"/>
  337. </xsl:param>
  338. <xsl:param name="verbose" select="1"/>
  339. <xsl:choose>
  340. <xsl:when test="$empty.local.l10n.xml">
  341. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  342. <xsl:for-each select="document(key('l10n-lang', $lang)/@href)">
  343. <xsl:variable name="localization.node"
  344. select="key('l10n-lang', $lang)[1]"/>
  345. <xsl:if test="count($localization.node) = 0
  346. and $verbose != 0">
  347. <xsl:message>
  348. <xsl:text>No "</xsl:text>
  349. <xsl:value-of select="$lang"/>
  350. <xsl:text>" localization exists.</xsl:text>
  351. </xsl:message>
  352. </xsl:if>
  353. <xsl:variable name="context.node"
  354. select="key('l10n-context', $context)[1]"/>
  355. <xsl:if test="count($context.node) = 0
  356. and $verbose != 0">
  357. <xsl:message>
  358. <xsl:text>No context named "</xsl:text>
  359. <xsl:value-of select="$context"/>
  360. <xsl:text>" exists in the "</xsl:text>
  361. <xsl:value-of select="$lang"/>
  362. <xsl:text>" localization.</xsl:text>
  363. </xsl:message>
  364. </xsl:if>
  365. <xsl:for-each select="$context.node">
  366. <xsl:variable name="template.node"
  367. select="(key('l10n-template-style', concat($context, '#', $name, '#', $xrefstyle))
  368. |key('l10n-template', concat($context, '#', $name)))[1]"/>
  369. <xsl:choose>
  370. <xsl:when test="$template.node/@text">
  371. <xsl:value-of select="$template.node/@text"/>
  372. </xsl:when>
  373. <xsl:otherwise>
  374. <xsl:choose>
  375. <xsl:when test="contains($name, '/')">
  376. <xsl:call-template name="gentext.template">
  377. <xsl:with-param name="context" select="$context"/>
  378. <xsl:with-param name="name" select="substring-after($name, '/')"/>
  379. <xsl:with-param name="origname" select="$origname"/>
  380. <xsl:with-param name="purpose" select="$purpose"/>
  381. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  382. <xsl:with-param name="referrer" select="$referrer"/>
  383. <xsl:with-param name="lang" select="$lang"/>
  384. <xsl:with-param name="verbose" select="$verbose"/>
  385. </xsl:call-template>
  386. </xsl:when>
  387. <xsl:when test="$verbose = 0">
  388. <!-- silence -->
  389. </xsl:when>
  390. <xsl:otherwise>
  391. <xsl:message>
  392. <xsl:text>No template for "</xsl:text>
  393. <xsl:value-of select="$origname"/>
  394. <xsl:text>" (or any of its leaves) exists in the context named "</xsl:text>
  395. <xsl:value-of select="$context"/>
  396. <xsl:text>" in the "</xsl:text>
  397. <xsl:value-of select="$lang"/>
  398. <xsl:text>" localization.</xsl:text>
  399. </xsl:message>
  400. </xsl:otherwise>
  401. </xsl:choose>
  402. </xsl:otherwise>
  403. </xsl:choose>
  404. </xsl:for-each>
  405. </xsl:for-each>
  406. </xsl:for-each>
  407. </xsl:when>
  408. <xsl:otherwise>
  409. <xsl:for-each select="$l10n.xml"> <!-- We need to switch context in order to make key() work -->
  410. <xsl:for-each select="document(key('l10n-lang', $lang)/@href)">
  411. <xsl:variable name="local.localization.node"
  412. select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang])[1]"/>
  413. <xsl:variable name="localization.node"
  414. select="key('l10n-lang', $lang)[1]"/>
  415. <xsl:if test="count($localization.node) = 0
  416. and count($local.localization.node) = 0
  417. and $verbose != 0">
  418. <xsl:message>
  419. <xsl:text>No "</xsl:text>
  420. <xsl:value-of select="$lang"/>
  421. <xsl:text>" localization exists.</xsl:text>
  422. </xsl:message>
  423. </xsl:if>
  424. <xsl:variable name="local.context.node"
  425. select="$local.localization.node/l:context[@name=$context]"/>
  426. <xsl:variable name="context.node"
  427. select="key('l10n-context', $context)[1]"/>
  428. <xsl:if test="count($context.node) = 0
  429. and count($local.context.node) = 0
  430. and $verbose != 0">
  431. <xsl:message>
  432. <xsl:text>No context named "</xsl:text>
  433. <xsl:value-of select="$context"/>
  434. <xsl:text>" exists in the "</xsl:text>
  435. <xsl:value-of select="$lang"/>
  436. <xsl:text>" localization.</xsl:text>
  437. </xsl:message>
  438. </xsl:if>
  439. <xsl:variable name="local.template.node"
  440. select="($local.context.node/l:template[@name=$name
  441. and @style
  442. and @style=$xrefstyle]
  443. |$local.context.node/l:template[@name=$name
  444. and not(@style)])[1]"/>
  445. <xsl:choose>
  446. <xsl:when test="$local.template.node/@text">
  447. <xsl:value-of select="$local.template.node/@text"/>
  448. </xsl:when>
  449. <xsl:otherwise>
  450. <xsl:for-each select="$context.node">
  451. <xsl:variable name="template.node"
  452. select="(key('l10n-template-style', concat($context, '#', $name, '#', $xrefstyle))
  453. |key('l10n-template', concat($context, '#', $name)))[1]"/>
  454. <xsl:choose>
  455. <xsl:when test="$template.node/@text">
  456. <xsl:value-of select="$template.node/@text"/>
  457. </xsl:when>
  458. <xsl:otherwise>
  459. <xsl:choose>
  460. <xsl:when test="contains($name, '/')">
  461. <xsl:call-template name="gentext.template">
  462. <xsl:with-param name="context" select="$context"/>
  463. <xsl:with-param name="name" select="substring-after($name, '/')"/>
  464. <xsl:with-param name="origname" select="$origname"/>
  465. <xsl:with-param name="purpose" select="$purpose"/>
  466. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  467. <xsl:with-param name="referrer" select="$referrer"/>
  468. <xsl:with-param name="lang" select="$lang"/>
  469. <xsl:with-param name="verbose" select="$verbose"/>
  470. </xsl:call-template>
  471. </xsl:when>
  472. <xsl:when test="$verbose = 0">
  473. <!-- silence -->
  474. </xsl:when>
  475. <xsl:otherwise>
  476. <xsl:message>
  477. <xsl:text>No template for "</xsl:text>
  478. <xsl:value-of select="$origname"/>
  479. <xsl:text>" (or any of its leaves) exists in the context named "</xsl:text>
  480. <xsl:value-of select="$context"/>
  481. <xsl:text>" in the "</xsl:text>
  482. <xsl:value-of select="$lang"/>
  483. <xsl:text>" localization.</xsl:text>
  484. </xsl:message>
  485. </xsl:otherwise>
  486. </xsl:choose>
  487. </xsl:otherwise>
  488. </xsl:choose>
  489. </xsl:for-each>
  490. </xsl:otherwise>
  491. </xsl:choose>
  492. </xsl:for-each>
  493. </xsl:for-each>
  494. </xsl:otherwise>
  495. </xsl:choose>
  496. </xsl:template>
  497. <!-- silently test if a gentext template exists -->
  498. <xsl:template name="gentext.template.exists">
  499. <xsl:param name="context" select="'default'"/>
  500. <xsl:param name="name" select="'default'"/>
  501. <xsl:param name="origname" select="$name"/>
  502. <xsl:param name="purpose"/>
  503. <xsl:param name="xrefstyle"/>
  504. <xsl:param name="referrer"/>
  505. <xsl:param name="lang">
  506. <xsl:call-template name="l10n.language"/>
  507. </xsl:param>
  508. <xsl:variable name="template">
  509. <xsl:call-template name="gentext.template">
  510. <xsl:with-param name="context" select="$context"/>
  511. <xsl:with-param name="name" select="$name"/>
  512. <xsl:with-param name="origname" select="$origname"/>
  513. <xsl:with-param name="purpose" select="$purpose"/>
  514. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  515. <xsl:with-param name="referrer" select="$referrer"/>
  516. <xsl:with-param name="lang" select="$lang"/>
  517. <xsl:with-param name="verbose" select="0"/>
  518. </xsl:call-template>
  519. </xsl:variable>
  520. <xsl:choose>
  521. <xsl:when test="string-length($template) != 0">1</xsl:when>
  522. <xsl:otherwise>0</xsl:otherwise>
  523. </xsl:choose>
  524. </xsl:template>
  525. </xsl:stylesheet>