1.1 --- a/XSLForms/XSL/Prepare.xsl Fri Dec 02 13:51:37 2005 +0000
1.2 +++ b/XSLForms/XSL/Prepare.xsl Fri Dec 02 13:52:19 2005 +0000
1.3 @@ -41,10 +41,8 @@
1.4 doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->
1.5
1.6 <!-- Include internationalisation (i18n) support if appropriate. -->
1.7 - <xsl:if test="//*[@template:i18n]">
1.8 - <axsl:param name="translations"/>
1.9 - <axsl:param name="locale"/>
1.10 - </xsl:if>
1.11 + <axsl:param name="translations"/>
1.12 + <axsl:param name="locale"/>
1.13
1.14 <axsl:template match="/">
1.15
1.16 @@ -158,15 +156,6 @@
1.17 <xsl:when test="@template:effect = 'replace'">
1.18 <xsl:call-template name="special-value"/>
1.19 </xsl:when>
1.20 - <xsl:when test="@template:i18n != '' and @template:i18n != '-'">
1.21 - <xsl:copy>
1.22 - <xsl:apply-templates select="@*"/>
1.23 - <xsl:call-template name="translated-values">
1.24 - <xsl:with-param name="values" select="@template:i18n"/>
1.25 - </xsl:call-template>
1.26 - <xsl:call-template name="expression-attributes"/>
1.27 - </xsl:copy>
1.28 - </xsl:when>
1.29 <xsl:otherwise>
1.30 <xsl:copy>
1.31 <xsl:apply-templates select="@*"/>
1.32 @@ -192,10 +181,8 @@
1.33 <axsl:value-of select="{@template:value}"/>
1.34 </xsl:when>
1.35 <!-- Insert the translated value. -->
1.36 - <xsl:when test="@template:i18n = '-'">
1.37 - <xsl:call-template name="translated-value">
1.38 - <xsl:with-param name="mode">contents</xsl:with-param>
1.39 - </xsl:call-template>
1.40 + <xsl:when test="@template:i18n">
1.41 + <xsl:call-template name="translated-value"/>
1.42 </xsl:when>
1.43 <!-- Just process the descendants. -->
1.44 <xsl:otherwise>
1.45 @@ -210,87 +197,41 @@
1.46
1.47 <xsl:template match="*[not(@template:if) and not(@template:element) and not(@template:attribute) and not(@template:value) and not(@template:expr) and @template:i18n]">
1.48 <xsl:copy>
1.49 - <xsl:choose>
1.50 - <xsl:when test="@template:i18n = '-'">
1.51 - <xsl:apply-templates select="@*"/>
1.52 - <xsl:call-template name="translated-value">
1.53 - <xsl:with-param name="mode">contents</xsl:with-param>
1.54 - </xsl:call-template>
1.55 - </xsl:when>
1.56 - <xsl:otherwise>
1.57 - <xsl:apply-templates select="@*"/>
1.58 - <xsl:call-template name="translated-values">
1.59 - <xsl:with-param name="values" select="@template:i18n"/>
1.60 - </xsl:call-template>
1.61 - </xsl:otherwise>
1.62 - </xsl:choose>
1.63 + <xsl:apply-templates select="@*"/>
1.64 + <xsl:call-template name="translated-value"/>
1.65 </xsl:copy>
1.66 </xsl:template>
1.67
1.68 - <xsl:template name="translated-values">
1.69 - <xsl:param name="values"/>
1.70 - <xsl:param name="this-value" select="substring-before($values, ',')"/>
1.71 - <xsl:param name="next-values" select="substring-after($values, ',')"/>
1.72 + <xsl:template name="translated-value">
1.73 <xsl:choose>
1.74 - <xsl:when test="$this-value != ''">
1.75 - <xsl:call-template name="translated-value">
1.76 - <xsl:with-param name="mode">attribute</xsl:with-param>
1.77 - <xsl:with-param name="attribute-name" select="$this-value"/>
1.78 - </xsl:call-template>
1.79 - <xsl:call-template name="translated-values">
1.80 - <xsl:with-param name="values" select="$next-values"/>
1.81 - </xsl:call-template>
1.82 + <!-- Look for a translation of the contents. -->
1.83 + <xsl:when test="@template:i18n = '-'">
1.84 + <!-- NOTE: Quoting not done completely. -->
1.85 + <axsl:variable name="translation"
1.86 + select="$translations/translations/locale[code/@value=$locale]/translation[@value='{text()}']/text()"/>
1.87 + <xsl:call-template name="insert-translated-value"/>
1.88 </xsl:when>
1.89 - <xsl:when test="$values != ''">
1.90 - <xsl:call-template name="translated-value">
1.91 - <xsl:with-param name="mode">attribute</xsl:with-param>
1.92 - <xsl:with-param name="attribute-name" select="$values"/>
1.93 - </xsl:call-template>
1.94 - </xsl:when>
1.95 - <xsl:otherwise/>
1.96 + <!-- Look for a named translation. -->
1.97 + <xsl:otherwise>
1.98 + <!-- NOTE: Quoting not done completely. -->
1.99 + <axsl:variable name="translation"
1.100 + select="$translations/translations/locale[code/@value=$locale]/translation[@value='{@template:i18n}']/text()"/>
1.101 + <xsl:call-template name="insert-translated-value"/>
1.102 + </xsl:otherwise>
1.103 </xsl:choose>
1.104 </xsl:template>
1.105
1.106 - <xsl:template name="translated-value">
1.107 - <xsl:param name="mode"/>
1.108 - <xsl:param name="attribute-name"/>
1.109 - <xsl:choose>
1.110 - <!-- Look for a translation for the contents. -->
1.111 - <xsl:when test="$mode = 'contents'">
1.112 - <!-- NOTE: Quoting not done completely. -->
1.113 - <!-- NOTE: Guard against scoping issues by generating a special name. -->
1.114 - <axsl:variable name="translation-{$attribute-name}"
1.115 - select="$translations/translations/locale[code/@value=$locale]/translation[@value='{text()}']/text()"/>
1.116 - <axsl:choose>
1.117 - <!-- Insert the translated value. -->
1.118 - <axsl:when test="$translation-{$attribute-name}">
1.119 - <axsl:value-of select="$translation-{$attribute-name}"/>
1.120 - </axsl:when>
1.121 - <!-- Otherwise, just process the descendants. -->
1.122 - <axsl:otherwise>
1.123 - <xsl:apply-templates select="node()"/>
1.124 - </axsl:otherwise>
1.125 - </axsl:choose>
1.126 - </xsl:when>
1.127 - <!-- Look for a translation for an attribute. -->
1.128 - <xsl:otherwise>
1.129 - <!-- NOTE: Quoting not done completely. -->
1.130 - <!-- NOTE: Guard against scoping issues by generating a special name. -->
1.131 - <xsl:variable name="attribute-value" select="@*[local-name() = $attribute-name]"/>
1.132 - <axsl:variable name="translation-{$attribute-name}"
1.133 - select="$translations/translations/locale[code/@value=$locale]/translation[@value='{$attribute-value}']/text()"/>
1.134 - <axsl:choose>
1.135 - <!-- Insert the translated value. -->
1.136 - <axsl:when test="$translation-{$attribute-name}">
1.137 - <axsl:attribute name="{$attribute-name}"><axsl:value-of select="$translation-{$attribute-name}"/></axsl:attribute>
1.138 - </axsl:when>
1.139 - <!-- Otherwise, just process the attribute. -->
1.140 - <axsl:otherwise>
1.141 - <axsl:attribute name="{$attribute-name}"><xsl:value-of select="$attribute-value"/></axsl:attribute>
1.142 - </axsl:otherwise>
1.143 - </axsl:choose>
1.144 - </xsl:otherwise>
1.145 - </xsl:choose>
1.146 + <xsl:template name="insert-translated-value">
1.147 + <axsl:choose>
1.148 + <!-- Insert the translated value. -->
1.149 + <axsl:when test="$translation">
1.150 + <axsl:value-of select="$translation"/>
1.151 + </axsl:when>
1.152 + <!-- Otherwise, just process the descendants. -->
1.153 + <axsl:otherwise>
1.154 + <xsl:apply-templates select="node()"/>
1.155 + </axsl:otherwise>
1.156 + </axsl:choose>
1.157 </xsl:template>
1.158
1.159