forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gav...." <brightoncomput...@brightontown.com.au>
Subject RE: i18n/dispatcher: language selection contract
Date Thu, 14 Sep 2006 14:38:53 GMT
Hi Sjur,

> -----Original Message-----
> From: Sjur Moshagen [mailto:sjurnm@mac.com]
> Sent: Thursday, 14 September 2006 8:26 PM
> To: dev@forrest.apache.org
> Subject: i18n/dispatcher: language selection contract
> 
> Hello,
> 
> 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:
>     X.YY.xml
>     X.ZZ.xml
>     X.xml
>     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
> available)
> 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" />
>            </forrest:hook>

Looks good, but I removed the word TEST.

> 
> but it only returns an empty
> 
> <div class="languages"/>

Yep, me too, but ....

> 
> for the hook. The first version of the contract, located in
> {$project}/resources/themes/common/html/language-variants.ft,
> contains the following:

To be available for all themes this is the place to put it, but if
You are only using it in pelt theme and only declaring it in pelt.fv
Then putting it in /themes/pelt/html/language-variants.ft makes better
Sense, but does not make any difference to this working or not as 
Common is fallback location, just thought I'd mention it.

> 
> <?xml version="1.0" encoding="UTF-8"?>
> <forrest:contract
>    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
>    xmlns:forrest="http://apache.org/forrest/templates/1.0"
>    name="language-variants">
> 
>    <description>
>      <p>
>      <strong>language-variants</strong> will output a list of
> available language for a given
>      input document. The presently displayed language will be marked.
> Styling
>      is done using CSS.
>      </p>
>    </description>
>    <usage><![CDATA[<forrest:contract name="language-variants"
>    dataURI="cocoon://#{$getRequest}.languages.xml"/>]]></usage>
>    <forrest:template xmlns:forrest="http://apache.org/forrest/
> templates/1.0"
>      name="language-variants" inputFormat="xsl">
>      <xsl:stylesheet version="1.1"
>        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>        <xsl:template match="/">
>        debug string -
>          <forrest:content>
>            <forrest:part>
>              <xsl:comment>+ |start language list +</xsl:comment>
>              <div class="language-variants">
>                SME
>              </div>
>              <xsl:comment>+ |end language list +</xsl:comment>
>            </forrest:part>
>          </forrest:content>
>        </xsl:template>
>      </xsl:stylesheet>
>    </forrest:template>
> </forrest:contract>
> 
> I would hve expected it to output "SME", but nothing shows up.

It is looking good, two things to note here, having the 'debug string -'
Gives an error message output to the console and is a good help.
Unfortunatly it also makes this script fail, removing it cured it for me.

I also had a failure of 

    <forrest:template xmlns:forrest="http://apache.org/forrest/
 templates/1.0"

because they were separate, this may be a cut-n-paste thing on my part if
the mail was wrapped.

HTH

Gav...


> 
> I have tried to read and follow the instructions at:
> 
> http://forrest.apache.org/docs_0_80/howto/howto-structurer-
> contracts.html
> 
> and related pages linked to at the bottom.
> 
> Any guidance would be greatly appreciated!
> 
> Best regards,
> Sjur
> 
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.3/446 - Release Date: 9/12/2006




Mime
View raw message