xsl-list
[Top] [All Lists]

Re: [xsl] i18n and l10n question

2006-11-06 09:25:44

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>