1.1 --- a/XSLForms/XSL/Prepare.xsl Fri Mar 17 18:05:21 2006 +0000
1.2 +++ b/XSLForms/XSL/Prepare.xsl Fri Mar 17 18:07:09 2006 +0000
1.3 @@ -230,14 +230,14 @@
1.4
1.5 <xsl:template name="special-value">
1.6 <xsl:choose>
1.7 + <!-- Insert the translated value. -->
1.8 + <xsl:when test="@template:i18n">
1.9 + <xsl:call-template name="translated-value"/>
1.10 + </xsl:when>
1.11 <!-- Insert the stated value. -->
1.12 <xsl:when test="@template:value">
1.13 <axsl:value-of select="{@template:value}"/>
1.14 </xsl:when>
1.15 - <!-- Insert the translated value. -->
1.16 - <xsl:when test="@template:i18n">
1.17 - <xsl:call-template name="translated-value"/>
1.18 - </xsl:when>
1.19 <!-- Copy the stated expression. -->
1.20 <xsl:when test="@template:copy">
1.21 <axsl:copy-of select="{@template:copy}"/>
1.22 @@ -269,6 +269,17 @@
1.23 select="$translations/translations/locale[code/@value=$locale]/translation[@value='{text()}']/text()"/>
1.24 <xsl:call-template name="insert-translated-value"/>
1.25 </xsl:when>
1.26 + <!-- Look for a translation based on the expression. -->
1.27 + <xsl:when test="starts-with(@template:i18n, '{') and substring(@template:i18n, string-length(@template:i18n), 1) = '}'">
1.28 + <!-- Select the expression. -->
1.29 + <axsl:variable name="i18n-expr" select="{substring(@template:i18n, 2, string-length(@template:i18n) - 2)}"/>
1.30 + <!-- Translate according to the expression. -->
1.31 + <axsl:variable name="translation"
1.32 + select="$translations/translations/locale[code/@value=$locale]/translation[@value=$i18n-expr]/text()"/>
1.33 + <xsl:call-template name="insert-translated-value">
1.34 + <xsl:with-param name="default">$i18n-expr</xsl:with-param>
1.35 + </xsl:call-template>
1.36 + </xsl:when>
1.37 <!-- Look for a named translation. -->
1.38 <xsl:otherwise>
1.39 <!-- NOTE: Quoting not done completely. -->
1.40 @@ -280,6 +291,7 @@
1.41 </xsl:template>
1.42
1.43 <xsl:template name="insert-translated-value">
1.44 + <xsl:param name="default"/>
1.45 <axsl:choose>
1.46 <!-- Insert the translated value. -->
1.47 <axsl:when test="$translation">
1.48 @@ -287,7 +299,14 @@
1.49 </axsl:when>
1.50 <!-- Otherwise, just process the descendants. -->
1.51 <axsl:otherwise>
1.52 - <xsl:apply-templates select="node()"/>
1.53 + <xsl:choose>
1.54 + <xsl:when test="$default">
1.55 + <axsl:value-of select="{$default}"/>
1.56 + </xsl:when>
1.57 + <xsl:otherwise>
1.58 + <xsl:apply-templates select="node()"/>
1.59 + </xsl:otherwise>
1.60 + </xsl:choose>
1.61 </axsl:otherwise>
1.62 </axsl:choose>
1.63 </xsl:template>