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>

but it only returns an empty

<div class="languages"/>

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

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

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