ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] i18n and l10n question
by Nicolas Van Cleemput other posts by this author
Nov 7 2006 1:25AM messages near this date
[xsl] i18n and l10n question | Re: [xsl] i18n and l10n question
& XSLT Hi,

I'm still having some problems putting this to use in our case, but I
thank you
already because I've learned some new ways of doing things from this, (As you
might have guessed: these are my first steps in XSL).

I tried to adjust your tip to what we already had, but it didn't seem to work.
It gave no errors (after I closed some brackets and typed some extra commas
;)), but it just printed the default text several times.

I will give a more concrete example on how I changed your file.

First of all, this is my example source file, named TuranGraphFactory.xml:

<factory> 
  <i18n> 
     <properties> 
         <entry key="factory.name"> Turán Graph</entry>
     </properties> 
     <node name="nl"> 
       <properties> 
           <entry key="factory.name"> Turán Graaf</entry>
       </properties> 
     </node> 
  </i18n> 
</factory> 

I made this xslt-file that should transform the TuranGraphFactory.xml
file to a
html-file:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

    <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="factory"> 
        <html> 
            <body> 
                <h1> 
                    <xsl:variable name="key" select="'factory.name'"/> 
                    <xsl:for-each select="//entry"> 
                    <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> 
                    </xsl:for-each> 
                </h1> 
            </body> 
        </html> 
    </xsl:template> 
</xsl:transform> 

The desired result would be a simple html-file that contained one title
with the
name of the graph in the current locale. However I get a file that
contains one
title that is the name of the graph four times: first the english, then the
dutch, then the english and again the dutch.

Any help would really be appreciated.

Nico van Cleemput

Quoting David Carlisle <davidc@[...].uk> :

> 
>  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@[...].com>
>  --~--
> 
> 





--~------------------------------------------------------------------
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@[...].com> 
--~--
Thread:
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput
Nicolas Van Cleemput

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved