[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Multilanguage help

Subject: Re: Multilanguage help
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Wed, 22 Feb 2006 21:49:44 +0100 (CET)
multilanguage help system
Antsnio Mota wrote:

> 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') />

  It's a way of doing this, sure.  And it works quite well for very
simple cases.  But the problem with I18N and L10N is the order of the
variable pieces of text, like amounts, numbers of chapter, nouns, etc.
(and it unfortunately always occurs while the L10N step).

  What I did here is the following.  I have such variables in my XSLT
script (the script is generated, but you can use doc() if you want,
this doens't matter):

    <xsl:variable name="l10n.all.entries">
      <l10n xml:lang="FR">
        <entry name="text">Un peu de texte.</entry>
        <entry name="chapter">Chapitre <num/></entry>
      </l10n>
      <l10n xml:lang="EN">
        <entry name="text">Some text.</entry>
        <entry name="chapter">Chapter <num/></entry>
      </l10n>
    </xsl:variable>

    <xsl:variable name="l10n.entries"
                  select="$l10n.all.entries/l10n[
                            xml:lang eq $l10n.lang ]"/>

  The example doesn't show the order problem, but I trust your
imagination.  In the document, I have elements like these:

    <title i18n="chapter">
      <param name="num" select="..."/>
    </title>
    <para i18n="text"/>

  With the help of a few functions for retrieving the right entry and
resolve the parameters, you get a more robust system, IMHO.  And you
can easily extend the parameters system.  I have for example 'choice'
elements (sort of hashtables):

    <entry name="...">... <what this='...' that='...'/>
      ...</entry>

    <para i18n="...">
      <choice name="what"
              select="if (...) then 'this' else 'that'"/>
    </para>

as well as more specific formating elements:

    <para i18n="...">
      <address name="who"
               who="this/guys"
               format="'%l %f, %S %s, %P %C'"/>
    </para>

  I'm sure other improvements can be done.  Like putting the format
string for an address in the placeholder in the entry, for example:

    <entry name="...">... <who fmt='...'/> ...</entry>

  Regards,

--drkm





















	

	
		
___________________________________________________________________________ 
Nouveau : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs exceptionnels pour appeler la France et l'international.
Tilichargez sur http://fr.messenger.yahoo.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.