You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by le...@cocoon.apache.org on 2004/07/23 23:21:41 UTC

[Cocoon Lenya Wiki] New: LanguageSwitchingHowto

   Date: 2004-07-23T14:21:41
   Editor: TorstenSchlabach <ts...@gmx.net>
   Wiki: Cocoon Lenya Wiki
   Page: LanguageSwitchingHowto
   URL: http://wiki.apache.org/cocoon-lenya/LanguageSwitchingHowto

   no comment

New Page:

= Language Switching in Multilingual Publications =

== Some Background ==

=== Setting up languages in a Lenya publication ===

=== HTTP Content Negotiation ===

== Language Switching Widgets ==

Lenya will start a session for each user and associate the language chosen with that session if it is not the default language. As long as the user is using the default language, all links inside the application are untouched and will contain just the document id, for example:

{{{
http://www.server.com/lenya/switchlanguage/authoring/subpage.html
}}}

Only if the user chooses to use a different language, all links in the page are automatically rewritten to point to specific language versions of the pages. If for example the user switches to Italian while englisch is the default language, the same link will read:

{{{
http://www.server.com/lenya/switchlanguage/authoring/subpage_it.html
}}}

=== Links pointing to a different language version ===

Switching the language is as easy as linking to a document with a different target language. Lenya will recognise that the user is requesting a different language than the current one assiciated with the user's session and replace the browsing language with the new one. That's all.

=== Global Language Switching Widgets ===

If you want to place the famous "language flags" in a fixed place to allow the user to switch to a different language at any given point in time, you can put these controls into the XSL template. By using some variables, you make sure that these links will always be generated correctly.

A modified page2xhtml.xsl might read like this:

{{{
...
      <div id="page">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td id="publication-title">Welcome to the Default Publication!</td>
          <td id="project-logo"><img src="{$root}/images/project-logo.png"/></td>
        </tr>
      </table>
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td>
            <a href="{$root}{$document-id}_de.html">DE</a>
          </td>
          <td>
            <a href="{$root}{$document-id}_en.html">EN</a>
          </td>
          <td>
            <a href="{$root}{$document-id}_it.html">IT</a>
          </td>
        </tr>
      </table>
      <xsl:apply-templates select="xhtml:div[@id = 'tabs']"/>
...
}}}

Note the <a> tags:

{{{
<a href="{$root}{$document-id}_de.html">DE</a>
}}}


---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org