forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira>
Subject Re: i18n suggestion
Date Tue, 16 Mar 2004 09:58:37 GMT
Sjur Nørstebø Moshagen wrote:


>>> 1) i18nFile generator:
>> Okay, as I said in a previous mail, I think we might do better with 
>> an Input Module: I18NModule. This would enable you to say something 
>> like:
>> <map:match pattern="**/*.html">
>>  <map:generate src="{1}/{i18n:{2}.{locale}.xml}"/>
>> So, we'd be using the file generator still, as all we need is a 
>> filename conversion. And so long as we can come up with a suitable 
>> module syntax, it should be easier to implement.
> Sounds fine (you are the expert here, I'm just trying to understand 
> and learn Cocoon;) 

As you'll see, I'm learning too. I posted a message on dev@cocoon, and 
Vadim suggested the LocaleAction. Thus, with the following sitemap code, 
we've got what we want:


  <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 test="{../1}/{../2}.{lang}.xml">
           <map:generate src="{../1}/{../2}.{lang}.xml"/>
          <map:generate src="{../1}/{../2}.{global:default-lang}.xml"/>
    <map:transform src="....."/>

You define the default language at the top of your <map:pipelines> 
element in the <global-variables> element.

Then, using the LocaleAction, you get hold of the language, country and 
variant (doesn't offer encoding at the mo). Then, using the 
ResourceExistsSelector, you go through each option, trying to see if an 
XML file exists. If it does, you use it, if it doesn't, you try the 
next. In the end, you check the default language. If that doesn't exist 
- you show an error (with the <map:handle-errors> block).

With that, I think we've got everything we need.


>> One remaining point: how do we handle crawling? Do we crawl a page, 
>> then seek all translations of it, or do we crawl from each language's 
>> homepage, following links that way? Make sense?
> ...
>> a.html <en
>> a.html <de
>> b.html <en
>> b.html <de
>> c.html <en
>> c.html <de
>> d.html <en
>> d.html <de
> Maybe this? That is, crawl a page, then all translations of it?

If we do this, we slow things down (in that we will get a lot of broken 
pages for language versions that don't exist, and we will break the use 
of broken-link handling to spot errors in the site. Or, if we have 
default language technology in place, the site would return the default 
language for each and every non-existent source file. So we could have 
foo.en.html,,, all containing the English 
version of the site. Actually, what we want is for the dynamic version 
of the site to serve the default language, and the static version to 
throw an error - which causes no page to be written.

On the other hand, if we use my other method - crawling from each 
language's homepage one at a time, if there are any language pages that 
can't be reached directly from that language's homepage, then they won't 
be generated. But maybe, if a page can't be reached from its language's 
homepage, there is some kind of error in the site? WDYT?

So therefore, I think I tend to err more towards crawling from each 
language's homepage, rather than checking every page for every language.

Any thoughts?


View raw message