You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Upayavira <uv...@upaya.co.uk> on 2004/03/15 17:08:20 UTC

I18N and multiple source files

It seems that Cocoon's I18N code is more geared towards 
internationalisation of 'webapps' rather than static sites.

It deals with menu items, etc, taking the various translations from 
catalog files, as necessary.

However, when you want to build a static site, where the entire content 
is in different languages, you need a way to pick the right file at the 
generator stage.

Therefore, I think we need an I18N input module. It would do something like:

<map:match pattern="**/*.html">
  <map:generate src="{1}/{i18n:{2}.{locale}.xml"/>
  ...
</map:match>

[NB. I'm not sure if nested input modules are allowed, so the syntax 
might need to change, but the idea should be sound]

So, here you can specify that, if the user requests userdocs/index.html, 
with a locale of de, you want to use userdocs/index.de.xml as your 
source file.

Two other areas that it should support:
(1) If the user specifies preferences in terms of locale, it should 
serve back the page most suiting their preference, e.g they might supply 
de, en, saying they prefer German, but English would be okay.
(2) If a translation in the user's language does not exist, it should 
offer a page in the 'default' language.

Does this make sense as a proposition?

If so, two questions:
(1) How best to represent the syntax of this, which will need to give 
access to values from matchers, and to the current locale
(2) What code in the I18N codebase could be reused to achive this?

For more info on where this came from see these threads on forrest-dev:
http://marc.theaimsgroup.com/?l=forrest-dev&m=107934498216665&w=2
http://marc.theaimsgroup.com/?l=forrest-dev&m=107935916929536&w=2
http://marc.theaimsgroup.com/?l=forrest-dev&m=107936342115987&w=2

Regards, Upayavira



Re: I18N and multiple source files

Posted by Upayavira <uv...@upaya.co.uk>.
Vadim Gritsenko wrote:

> Upayavira wrote:
>
>> It seems that Cocoon's I18N code is more geared towards 
>> internationalisation of 'webapps' rather than static sites.
>>
>> It deals with menu items, etc, taking the various translations from 
>> catalog files, as necessary.
>>
>> However, when you want to build a static site, where the entire 
>> content is in different languages, you need a way to pick the right 
>> file at the generator stage.
>
>
>
> I think you missed LocaleAction.
>
>
> ...
>
>> Two other areas that it should support:
>> (1) If the user specifies preferences in terms of locale, it should 
>> serve back the page most suiting their preference, e.g they might 
>> supply de, en, saying they prefer German, but English would be okay.
>> (2) If a translation in the user's language does not exist, it should 
>> offer a page in the 'default' language.
>
>
>
> From this description it sound like combination of LocaleAction and 
> ResourceExistAction is what you need. 

Or ResourceExistsSelector, and the globals input module:

<map:pipelines>
  <map:component-configurations>
    <global-variables>
        <default-lang>en</default-lang>
    </global-variables>
  </map:component-configurations>

  <map:pipeline>
  <map:match pattern="**/*.html">
    <map:act type="locale">
     <map:select type="resource-exists">
       <map:when test="{../1}/{../2}.{lang}-{country}.xml">
           <map:generate src="{../1}/{../2}.{lang}-{country}.xml"/>
        </map:when>
        <map:when test="{../1}/{../2}.{lang}.xml">
           <map:generate src="{../1}/{../2}.{lang}.xml"/>
        </map:when>
        <map:otherwise>
          <map:generate src="{../1}/{../2}.{global:default-lang}.xml"/>
        </map:otherwise>
      </map:select>
    </map:act>
    <map:transform src="....."/>
    <map:serialize/>
  </map:match>
</map:pipeline>

So, the globals input module allows you to specify the default language, 
and you can build up your page name. Oh for the arrival of virtual 
sitemap components, this would make such a neat one: the i18nGenerator.

Thanks so much for this Vadim - I think this gets us pretty much where 
we want to go.

Regards, Upayavira



Re: I18N and multiple source files

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Upayavira wrote:

> It seems that Cocoon's I18N code is more geared towards 
> internationalisation of 'webapps' rather than static sites.
>
> It deals with menu items, etc, taking the various translations from 
> catalog files, as necessary.
>
> However, when you want to build a static site, where the entire 
> content is in different languages, you need a way to pick the right 
> file at the generator stage.


I think you missed LocaleAction.


...

> Two other areas that it should support:
> (1) If the user specifies preferences in terms of locale, it should 
> serve back the page most suiting their preference, e.g they might 
> supply de, en, saying they prefer German, but English would be okay.
> (2) If a translation in the user's language does not exist, it should 
> offer a page in the 'default' language.


 From this description it sound like combination of LocaleAction and 
ResourceExistAction is what you need.

Vadim