cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Ulrich Niedermann <>
Subject Re: [C2]I18n transformer
Date Sat, 04 Nov 2000 13:28:06 GMT

I want to present another solution for "small" multi-lingual sites,
one I have created during the last two weeks or so. In this context,
"small" means that the same content writers writes all translations.

Lassi Immonen <> writes:

> In attachment is C2 I18nTtransformer, which is port from Infozones
> I18NProcessor.

> Usage:
> ---------
> Sitemap:
> <map:match pattern="">
>   <map:generate src="orig.xml"/>
>     <map:transform type="translate">
>       <parameter name="default_lang" value="en"/>
>       <parameter name="src" value="orig_trans.xml"/>    
>     </map:transform>
>     <map:transform src="simple2html.xsl"/>
>     <map:serialize type="html"/>
> </map:match>
> ---------
> orig.xml:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <lang_test 
> 	xmlns:i="">
> 	<title><i:tr>Title</i:tr></title>
> 	<para i:tr="y">Paragraph</para>
> 	<para>Paragraph not to be translated</para>
> </lang_test>
> -----------
> orig_trans.xml:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <translations>
>   <entry>
>     <key>Title</key>
>       <translation lang="fi">Otsikko</translation>
>       <translation lang="sv">Titel</translation>
>   </entry>
>   <entry>
>     <key>Paragraf</key>
>       <translation lang="fi">Paragraafi</translation>
>       <translation lang="sv">Paragraf</translation>
>   </entry>
> </translations>
> --------
> So I modified syntax a bit from I18NProcessor. Now you have to put all
> translations in one translation file, which is in my opinion better at
> least small sites as we are doing.

If you already say that you have a small site with only one file that
contains all translations, I do not understand why do it so
complicated with two different files. My solution (which badly
needed cleaning up during the last few days, so I only post it now)
does the same with less file hassle, I think (no offense intended):

======== <original.xml> =============================================
<?xml version="1.0" encoding="iso-8859-1"?>
<page xmlns=""
      lang:langset="de en">

  <header xml:lang="en">
    <title>The small i18n solution</title>

  <header xml:lang="de">
    <title>Die kleine i18n Lösung</title>

    <para xml:lang="de">Kleiner Versuch</para>
    <para xml:lang="en">Small test</para>

======== </original.xml> ============================================

The transformer (PML Transformer, Poor Man's Language Transformer) now
takes it language from HTTP Content negotiation, from a HTTP request
param or the default and filters out all elements that have a xml:lang
attribute of an undesired language. So the english ("en") version of
above file looks as follows: 

======== <original.en.xml> ==========================================
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns=""
      lang:langset="de en">

    <title>The small i18n solution</title>

    <para>Small test</para>

======== </original.en.xml> ==========================================

A sitemap entry looks almost the same as the one using

======== <sitemap.xmap> ==============================================
      <map:match pattern="lang/pml/html">
        <map:generate src="original.xml"/>
        <map:transform type="pml">
          <parameter name="lang" value="en"/>
        <map:transform src="test2html.xsl"/>
        <map:serialize type="html"/>
======== </sitemap.xmap> =============================================

Transformer source code is attached, should anyone be interested.


View raw message