An action that locates and provides to the pipeline locale information
looked up in a range of ways.
Configuration
A sample configuration (given in the <map:matchers> section of the
sitemap) is given below. This configuration shows default values.
<map:action name="locale" src="org.apache.cocoon.acting.LocaleAction">
<locale-attribute>locale</locale-attribute>
<use-locale>true</use-locale>
<default-locale language="en" country="US"/>
<store-in-request>false<store-in-request>
<create-session>false<create-session>
<store-in-session>false<store-in-session>
<store-in-cookie>false<store-in-cookie>
</map:action>
Above configuration parameters mean:
- locale-attribute specifies the name of the request
parameter / session attribute / cookie that is to be used as a locale
(defaults to
locale )
- use-locale specifies whether the primary locale provided
by the user agent (or server default, is no locale passed by the agent)
is to be used
- default-locale specifies the default locale to be used when
none found.
- store-in-request specifies whether found locale should be
stored as request attribute.
- create-session specifies whether session should be created
when storing found locale as session attribute.
- store-in-session specifies whether found locale should be
stored as session attribute.
- store-in-cookie specifies whether found locale should be
stored as cookie.
Usage
This action will be used in a pipeline like so:
<map:act type="locale">
<map:generate src="file_{language}_{country}_{variant}.xml"/>
...
</map:match>
or
<map:act type="locale">
<map:generate src="file_{locale}.xml"/>
...
</map:match>
Locale Identification
Locales will be tested in following order:
- Locale provided as a request parameter
- Locale provided as a session attribute
- Locale provided as a cookie
- Locale provided using a sitemap parameter
(<map:parameter name="locale" value="{1}"/> style parameter within
the <map:match> node)
- Locale provided by the user agent, or server default,
if
use-locale is set to true
- The default locale, if specified in the matcher's configuration
First found locale will be returned.
Sitemap Variables
Once locale has been found, the following sitemap variables
will be available to sitemap elements contained within the action:
- {locale}: The locale string
- {language}: The language of the found locale
- {country}: The country of the found locale
- {variant}: The variant of the found locale
author: Marcus Crafter author: Konstantin Piroumian author: Lassi Immonen author: Vadim Gritsenko version: CVS $Id: LocaleAction.java 433543 2006-08-22 06:22:54Z crossley $ |