Re: [xsl] Multilanguage help

Subject: Re: [xsl] Multilanguage help
From: António Mota <amsmota@xxxxxxxxx>
Date: Wed, 15 Feb 2006 08:37:28 +0000
Extremely easy to do with the document() function. I don't have my XML
tools here but from the top of my head it's something like this:

Supose you have a XML like this

xml_pt.xml

<translations>
    <word id='Descripcion'>Descrigco</word>
   (...)
</translations>

then, in your xsl you should have something that tell what the
language to translate to, a param for instance. Supose you pass 'pt'
to it.

<xsl:param name="lang"/>
<xsl:variable name="filename" select="concat('/filepath/xml_',$lang,'.xml')
/>

and later on instead of

<td class="inici">Descripcion       </td>

you'll have

<td class="inici">
   <xsl:value-of
select="document($filename)/translations/word[@id='Descripcion']
 </td>

and that's it.

Of course you can pass the filename alltogether in the param and avoid
that concat().

This is not tested at all.

Hope it helps.

On 15/02/06, Guillem Rico <grico@xxxxxxxxxx> wrote:
> Ok,
>
> I have a data XML linked to a XSL file.
> This XSL file outputs the contents of that XML file (no problem).
>
> The real problem I have is I want to output the table titles of my xsl file
> in several languages (spanish, catalan, portuguese, english), and I don't
> want to change from 1 only XSL file to four.
>
>
> A simple example like this:
> (My actual and only XSL):
>
>          <td class="inici">Descripcion       </td>
>          <td class="inici">N                        </td>
>
>
> In catalan should output:
>
>         Descripcis  | N
>
> In english:
>         Description      | N
> .
> .
>
>
> I hope there is a simple way to do it, and I'm thinking the best option, so
> I consider you could help me (If I've explained it clearly).
>
> Thanks
>
>
> -----Mensaje original-----
> De: Vasu Chakkera [mailto:vasucv@xxxxxxxxxxx]
> Enviado el: miircoles, 15 de febrero de 2006 0:25
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Asunto: RE: [xsl] Multilanguage help
>
> tell us exactly what you want to do..there could be other ways of doing the
> same.
> give us an example of what you want.and someone would be able to suggest
you
>
> ways.
>
>
> >From: "Guillem Rico" <grico@xxxxxxxxxx>
> >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> >To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> >Subject: [xsl] Multilanguage help
> >Date: Tue, 14 Feb 2006 18:16:14 +0100
> >
> >
> >Hi, I'm trying  to do a Multilanguage XSL, but I don't know how...
> >
> >I have a XML file (with data), and the XML is Ok translated, So I only
need
> >to transalte Fields of tables placed into XSL...
> >
> >I think I could store the translations maybe in another XML, but I don't
> >know how to call the another XSL into an XSL (if I could), or wich is the
> >best way to do it
> >
> >I don't know what to do...any ideas??
> >
> >I'm a XSL begginner, please if you could send some examples
> >
> >Thanks
> >
> >
> >
> >
> >
> >.
> >
> >.
> >
> >.
> >
> >.
> >
> ><table border="0" cellpadding="0" cellspacing="0"
> >width="90%"align="center">
> >
> >
> ><xsl:variable name="serv" select="/PICA/DATA/REGISTRE/Servicio" />
> >
> ><tr><td align='right'><ahref="../datos/fr.html?serv={$serv}?t=t">Todos
> ></a>
> >
> ><a href="../datos/fr.html?serv={$serv}?t=2">Quirzrgicos  </a>
> >
> ><a href="../datos/fr.html?serv={$serv}?t=1">Midicos</a></td></tr>
> >
> ></table>
> >
> >
> >
> ><table border="0" cellpadding="0" cellspacing="0"
> >width="90%"align="center">
> >
> >       <tr>
> >
> >                         <td class="inici"> Grd
> ></td>
> >
> >                         <td class="inici">CDM
> ></td>
> >
> >                         <td class="inici" width="3%">T     </td>
> >
> >                         <td class="inici">Descripcion       </td>
> >
> >                         <td class="inici">N
> ></td>
> >
> >                         <td class="inici">PNh
> ></td>
> >
> >                         <td class="inici">PNstd
> ></td>
> >
> >                         <td class="inici">Nobs-Nesp              </td>
> >
> >                         <td class="inici">Peso
> ></td>       </tr>
> >
> >
> >
> >
> >
> >
> >
> >       <xsl:for-each select="PICA/DATA/REGISTRE">
> >
> >       <xsl:sort data-type="number" select="N" order="descending" />
> >
> >
> >
> >       <tr>
> >
> >       <xsl:choose>
> >
> >       <xsl:when test="position() &lt; '20'">
> >
> >       <xsl:choose>
> >
> >.
> >
> >.
> >
> >.
> >
> >.
> >
>
> _________________________________________________________________
> Are you using the latest version of MSN Messenger? Download MSN Messenger
> 7.5 today! http://messenger.msn.co.uk

Current Thread