RE: internationalization / localization of XSLT output

Subject: RE: internationalization / localization of XSLT output
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Thu, 24 Aug 2000 14:57:22 +0100
What about
<strings>
   <str lang="en" name="Results of database query">Results of database
query</str>
   <str lang="de" name="Results of database query">Ergebnis der
Datenbankabfrage</str>
   <str lang="en" name="next page">next page</str>
   <str lang="de" name="next page">naechste Seite</str>
</strings>

<xsl:param name="lang"/> <!-- param set in command line -->
<html>
  <body>
   <h1><xsl:value-of select="/strings/str[@name='Results of database query'
and @lang=$lang]"/>
    </h1>

or with the same master xml generate xml for each language with a simple
transform

<xsl:template match="str">
</xsl:template>
<xsl:template match="str[@lang=$lang]">
	<xsl:copy-of select="." />
</xsl:template>

then use the w3c aproach or create one language file first depending on the
language

<xsl:variable name="strs" select="document('language.xml')/strings"/>
<html>
  <body>
   <h1><xsl:value-of select="$strs/str[@name='Results of database query']"/>
    </h1>

or

<xsl:param name="lang"/> <!-- param set in command line -->
<xsl:variable name="strs"
select="document('master.xml')/strings/str[@lang=$lang]"/>
<html>
  <body>
   <h1><xsl:value-of select="$strs/str[@name='Results of database query']"/>
    </h1>

All seem better than the entity approach

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Stephan.Otte@xxxxxx
>Sent: 24 August 2000 13:51
>To: XSL-List@xxxxxxxxxxxxxxxx
>Subject: internationalization / localization of XSLT output
>
>
>Hello,
>
>I'd like to transform the contents of XML-files to localized  HTML
>(english, german, french etc.)
>using only  *one * XSL stylesheet.
>
>My task is just to translate strings out of the XSL stylesheet. I do not
>need to have different formatting instructions.
>
>One approach (found at w3.org) is to use additional input files (one for
>each language) containing the translated strings.
>E.g. ge.xml for the german translation, fr.xml for the french as given
>below:
>
><!-- ----------- english "translation" file en.xml ----- -->
><strings>
>   <str name="Results of database query">Results of database query</str>
>   <str name="next page">next page</str>
></strings>
>
><!-- ---------  german translation file ge.xml ----- -->
><strings>
>   <str name="Results of database query">Ergebnis der
>Datenbankabfrage</str>
>   <str name="next page">naechste Seite</str>
></strings>
>
><!-- ------------------- XSL stylesheet ---------------- --->
>
><xsl:param name="lang"/> <!-- param set in command line -->
><xsl:variable name="loc" select="document( concat( $lang, '.xml'
>))/strings"/>
><html>
>  <body>
>   <h1><xsl:value-of select="$loc/str[@name='Results of database query']"/>
>    </h1>
>
>In my opinion the reference to the string seems to be a little bit to
>complicated so I don't like this approach very much.
>
>Another approach is to use entities for the strings which are defined in
>different external DTD files, one for each language.
>The reference would be much simpler.
>But because I want to have the english version of the string in the
>XSL-stylesheet,
>the entity would be referenced like "&Results_of_the_database_query;".
>Looks a bit curios, doesn't it?!  Also the possibility of typing errors is
>high.
>
>Apart from this I don't know how to include different DTDs depending on the
>language dynamically.
>Does anyone know how to do this?  (I use the Xalan XSLT-Processor on the
>command line.)
>
>As you see I´m not pleased with  these approaches, possibly because I use
>the very nice
>gettext mechanism for localizing C sourcecode.
>
>Finally, here is my question:
>Are there any other solutions for localization / internationalization XSLT
>output?
>
>Thanks,
>Stephan
>
>
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread