You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Lassi Immonen <li...@malla.urova.fi> on 2000/11/03 10:31:04 UTC

[C2]I18n transformer

Hi,

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

I don't have any license in there cause don't know which license to put
there?? 

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="http://apache.org/cocoon/i18n">
	<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.

I didn't include parameter substitutions from I18NProcessor, but it
wouldn't be big thing to add. I don't have such a need now. 

Thanks,

 Lassi Immonen

Re: [C2]I18n transformer

Posted by Lassi Immonen <li...@malla.urova.fi>.
> >
> > 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):


Actually I had posted a time ago same kind of LangTransformer which
stripped unwanted tags away :-)
The reason I did port Cocoon1 i18nProcessor is that in long run in my
opinion it's better solution to have translations in different file(s).
I didn't implement parameter substitution which is in Processor yet, but
thats another important aspect.
I think it's easier to give translation(s) files to actual translator,
than possibly XSP page with all other unneccessary stuff in it.

Lassi

Re: [C2]: Patch for bug in XercesParser

Posted by Ross Burton <ro...@mail.com>.
Carsten Ziegeler wrote:
> 
> The org.apache.cocoon.components.parser.XercesParser does not set the lexical handler correctly.
> The following line must be moved from the constructor to the parse() method:
> 
>    this.parser.setProperty("http://xml.org/sax/properties/lexical-handler",
>                       super.lexicalHandler);
> 
> During the constructor the (super.)lexicalHandler is not yet initialised, so the setting of the property was too early.

Fixed. Thanks!

Ross

[C2]: Patch for bug in XercesParser

Posted by Carsten Ziegeler <cz...@sundn.de>.
The org.apache.cocoon.components.parser.XercesParser does not set the lexical handler correctly.
The following line must be moved from the constructor to the parse() method:
	
   this.parser.setProperty("http://xml.org/sax/properties/lexical-handler",
	              super.lexicalHandler); 

During the constructor the (super.)lexicalHandler is not yet initialised, so the setting of the property was too early.

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================




Re: [C2]I18n transformer

Posted by Hans Ulrich Niedermann <nd...@n-dimensional.de>.
Hi!

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 <li...@mail.urova.fi> 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="http://apache.org/cocoon/i18n">
> 	<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="http://n-dimensional.de/webpage/1.0"
      xmlns:lang="http://n-dimensional.de/language/1.0"
      lang:langset="de en">

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

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

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

</page>
======== </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="http://n-dimensional.de/webpage/1.0"
      xmlns:lang="http://n-dimensional.de/language/1.0"
      xml:lang="en"
      lang:langset="de en">

  <header>
    <title>The small i18n solution</title>
  </header>

  <body>
    <para>Small test</para>
  </body>

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

A sitemap entry looks almost the same as the one using
I18nTransformer: 

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

Transformer source code is attached, should anyone be interested.

Uli


Re: [C2]I18n transformer

Posted by Conny Krappatsch <co...@smb-tec.com>.
On Fri, 03 Nov 2000 11:31:04 +0200
Lassi Immonen <li...@mail.urova.fi> wrote:
> Hi,
> 
> In attachment is C2 I18nTtransformer, which is port from Infozones
> I18NProcessor.

Great job,

I will have a look at it as soon as possible.

> I don't have any license in there cause don't know which license to put
> there?? 

Because it's a port from the Infozone I18NProcessor it's released under the Infozone license. We will add that before checking in Infozone CVS - with respect to your work, of course.

> 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.

You may be right that it's good for small sites, but it will get a pain for larger ones, especially if there are different interpreters for the different languages.

> I didn't include parameter substitutions from I18NProcessor, but it
> wouldn't be big thing to add. I don't have such a need now. 

Everybody is welcome to add this ;-)

Thanks for your effort,
Conny Krappatsch


-- 
______________________________________________________________________
Conny Krappatsch                              mailto:conny@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




Re: [C2]I18n transformer

Posted by Lassi Immonen <li...@malla.urova.fi>.
Berin Loritsch wrote:
> 
> ----- Original Message -----
> From: "Lassi Immonen" <li...@malla.urova.fi>
> To: "Conny Krappatsch" <co...@smb-tec.com>; <co...@xml.apache.org>
> Sent: Friday, November 03, 2000 4:31 AM
> Subject: [C2]I18n transformer
> 
> > Hi,
> >
> > In attachment is C2 I18nTtransformer, which is port from Infozones
> > I18NProcessor.
> >
> > I don't have any license in there cause don't know which license to put
> > there??
> >
> > 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="http://apache.org/cocoon/i18n">
> > <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.
> >
> > I didn't include parameter substitutions from I18NProcessor, but it
> > wouldn't be big thing to add. I don't have such a need now.
> 
> How different is it from the one in Avalon?  If it is the same, C2 already
> has it included.  If it is different, can you send me the diff and a quick
> summary of what you did?  The one in Avalon is the same as the one from
> infozone approx. 4 weeks ago.

What do you mean?
I couldn't find any I18NProcessor/Transformer in Avalon or C2. Where it
should be?

To summarize it:
It's C2 transformer which loads xml-file, eg. orig_trans.xml above, to
Hashtable according lang value it gets in Setup. 
After that it substitutes every occurrance of <i:tr>Text</i:tr> or
<some_elem i:tr="y">Text</some_elem> with value from Hashtable.

 Lassi

Re: [C2]I18n transformer

Posted by Berin Loritsch <bl...@infoplanning.com>.
----- Original Message ----- 
From: "Lassi Immonen" <li...@malla.urova.fi>
To: "Conny Krappatsch" <co...@smb-tec.com>; <co...@xml.apache.org>
Sent: Friday, November 03, 2000 4:31 AM
Subject: [C2]I18n transformer


> Hi,
> 
> In attachment is C2 I18nTtransformer, which is port from Infozones
> I18NProcessor.
> 
> I don't have any license in there cause don't know which license to put
> there?? 
> 
> 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="http://apache.org/cocoon/i18n">
> <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.
> 
> I didn't include parameter substitutions from I18NProcessor, but it
> wouldn't be big thing to add. I don't have such a need now. 

How different is it from the one in Avalon?  If it is the same, C2 already
has it included.  If it is different, can you send me the diff and a quick
summary of what you did?  The one in Avalon is the same as the one from
infozone approx. 4 weeks ago.