Re: [xsl] i18n and l10n question

Subject: Re: [xsl] i18n and l10n question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 6 Nov 2006 16:25:23 GMT
if the file you posted is in locale.xml and you have an input element
something like
<ref key="id1"/>
which is supposed to produce this text, then something like

<xsl:stylesheet...
<xsl:param name="locale"/> 
<xsl:variable  name="locale2" select="substring-before($locale,'-')"/> 
<xsl:key name="l" match="entry" use="concat(../@name,' ',@key)"/>

<xsl:template match="ref">
 <xsl:variable name="key" select="@key"/>
 <xsl:for-each select="document('locale.xml')">
  <xsl:choose>
   <xsl:when test="key('l',concat($locale,' '$key)">
      <xsl:apply-templates select="key('l',concat($locale,' ',$key)"/>
   </xsl:when>
   <xsl:when test="key('l',concat($locale2,' '$key)">
      <xsl:apply-templates select="key('l',concat($locale2,' ',$key)"/>
   </xsl:when>
   <xsl:otherwise>
      <xsl:apply-templates select="key('l',concat(' ',$key)"/>
   </xsl:otherwise>
   </xsl:choose>

which (if I typed it in right) would mean that setting the external
local parameter to "en-uk"  would mean it would try in order, en-uk, en,
and the defualt.

David

Current Thread