<xsl:key name="l10n-gentext" match="l:l10n/l:gentext" use="@key"/>
<xsl:key name="l10n-dingbat" match="l:l10n/l:dingbat" use="@key"/>
<xsl:key name="l10n-context" match="l:l10n/l:context" use="@name"/>
+<xsl:key name="l10n-template" match="l:l10n/l:context/l:template[not(@style)]" use="@name"/>
+<xsl:key name="l10n-template-style" match="l:l10n/l:context/l:template[@style]" use="concat(@name, '#', @style)"/>
<xsl:template name="l10n.language">
<xsl:param name="target" select="."/>
|$local.context.node/l:template[@name=$name
and not(@style)])[1]"/>
- <xsl:variable name="template.node"
- select="($context.node/l:template[@name=$name
- and @style
- and @style=$xrefstyle]
- |$context.node/l:template[@name=$name
- and not(@style)])[1]"/>
+ <xsl:for-each select="$context.node">
+ <xsl:variable name="template.node"
+ select="(key('l10n-template-style', concat($name, '#', $xrefstyle))
+ |key('l10n-template', $name))[1]"/>
- <xsl:choose>
- <xsl:when test="$local.template.node/@text">
- <xsl:value-of select="$local.template.node/@text"/>
- </xsl:when>
- <xsl:when test="$template.node/@text">
- <xsl:value-of select="$template.node/@text"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="contains($name, '/')">
- <xsl:call-template name="gentext.template">
- <xsl:with-param name="context" select="$context"/>
- <xsl:with-param name="name" select="substring-after($name, '/')"/>
- <xsl:with-param name="origname" select="$origname"/>
- <xsl:with-param name="purpose" select="$purpose"/>
- <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
- <xsl:with-param name="referrer" select="$referrer"/>
- <xsl:with-param name="lang" select="$lang"/>
- <xsl:with-param name="verbose" select="$verbose"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$verbose = 0">
- <!-- silence -->
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>
- <xsl:text>No template for "</xsl:text>
- <xsl:value-of select="$origname"/>
- <xsl:text>" (or any of its leaves) exists
- in the context named "</xsl:text>
- <xsl:value-of select="$context"/>
- <xsl:text>" in the "</xsl:text>
- <xsl:value-of select="$lang"/>
- <xsl:text>" localization.</xsl:text>
- </xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="$local.template.node/@text">
+ <xsl:value-of select="$local.template.node/@text"/>
+ </xsl:when>
+ <xsl:when test="$template.node/@text">
+ <xsl:value-of select="$template.node/@text"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="contains($name, '/')">
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="$context"/>
+ <xsl:with-param name="name" select="substring-after($name, '/')"/>
+ <xsl:with-param name="origname" select="$origname"/>
+ <xsl:with-param name="purpose" select="$purpose"/>
+ <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
+ <xsl:with-param name="referrer" select="$referrer"/>
+ <xsl:with-param name="lang" select="$lang"/>
+ <xsl:with-param name="verbose" select="$verbose"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$verbose = 0">
+ <!-- silence -->
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ <xsl:text>No template for "</xsl:text>
+ <xsl:value-of select="$origname"/>
+ <xsl:text>" (or any of its leaves) exists in the context named "</xsl:text>
+ <xsl:value-of select="$context"/>
+ <xsl:text>" in the "</xsl:text>
+ <xsl:value-of select="$lang"/>
+ <xsl:text>" localization.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
</xsl:for-each>
</xsl:template>