forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sjur Moshagen <>
Subject i18n/dispatcher: language selection contract
Date Thu, 14 Sep 2006 12:26:29 GMT

I'm trying to make my first dispatcher contract. It turned out to be  
more problematic than I first thought, problems below the pseudocode.

Here's what I want to do: I want to create a language selection list  
for a multilingual site. The language selection list should be  
dynamically generated for each document, since it isn't known which  
document have more than one language, and which languages are  
available for each document. The pseudocode goes like this:

1- get the request
2- get a list of all documents that matches the request, disregarding  
i18n infixes in the
    filenames (that is, a request for X.html should match all of:
    where YY, ZZ and <nothing> corresponds to available locales or  
the fallback file
3- examine the X.xml (fallback file) for an @xml:lang or @lang to  
determine the
    language of the document; if not found, use the site default (if  
4- based on 2 and 3, create a list of all languages available
5- examine the document actually being returned by the request for  
@xml:lang or @lang,
    to be able to detect the currently viewed language (it could be  
different from
    the fallback document, since other i18n components can have  
picked a better
    choice based on browser settings)
6- return a list of available language variants, tagging the  
presently displayed
    language, and with each of the other languages as a link to that  
document (using,
    e.g. ?locale=YY or some other means to override browser settings)

The list should be formatted with CSS to whatever is wanted. My  
present goal is to have a simple horisontal list across the page,  
between the menu on the left and the PDF icon on the right, just  
above the document title.

Problem #1:

I can't get the contract to do anything!

I have in my {$project}/resources/themes/pelt.fv the following snippet:

           <forrest:hook class="languages">TEST
             <forrest:contract name="language-variants" />

but it only returns an empty

<div class="languages"/>

for the hook. The first version of the contract, located in  
contains the following:

<?xml version="1.0" encoding="UTF-8"?>

     <strong>language-variants</strong> will output a list of  
available language for a given
     input document. The presently displayed language will be marked.  
     is done using CSS.
   <usage><![CDATA[<forrest:contract name="language-variants"
   <forrest:template xmlns:forrest=" 
     name="language-variants" inputFormat="xsl">
     <xsl:stylesheet version="1.1"
       <xsl:template match="/">
       debug string -
             <xsl:comment>+ |start language list +</xsl:comment>
             <div class="language-variants">
             <xsl:comment>+ |end language list +</xsl:comment>

I would hve expected it to output "SME", but nothing shows up.

I have tried to read and follow the instructions at: 

and related pages linked to at the bottom.

Any guidance would be greatly appreciated!

Best regards,

View raw message