org.apache.cocoon.matching
Class LocaleMatcher

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.matching.LocaleMatcher
All Implemented Interfaces:
Configurable, Disposable, org.apache.cocoon.matching.Matcher, Serviceable, ThreadSafe

public class LocaleMatcher
extends org.apache.cocoon.util.AbstractLogEnabled
implements org.apache.cocoon.matching.Matcher, ThreadSafe, Serviceable, Configurable, Disposable

A matcher that locates and identifies to the pipeline a source document to be used as the content for an i18n site, based upon a locale provided 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:matcher name="i18n" src="org.apache.cocoon.matching.LocaleMatcher">
     <locale-attribute>locale</locale-attribute>
     <negotiate>false</negotiate>
     <use-locale>true</use-locale>
     <use-locales>false</use-locales>
     <use-blank-locale>true</use-blank-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:matcher>
 

Above configuration parameters mean:

Usage

This matcher will be used in a pipeline like so:

   <map:match pattern="*.html">
     <map:match type="i18n" pattern="xml/{1}.*.xml">
       <map:generate src="{source}"/>
       ...
     </map:match>
   </map:match>
 

* in the pattern identifies the place where locale should be inserted. In case of a blank locale, if character before and after * is the same (like in example above), duplicate will be removed (xml/{1}.*.xml becomes xml/{1}.xml).

Locale Identification

Locales will be tested in following order:

If negotiate mode is set to true, a source will be looked up using each locale. Where the full locale (language, country, variant) doesn't match, it will fall back first to language and country, and then just language, before moving on to the next locale.

If negotiate mode is set to false (default), first found locale will be returned.

Sitemap Variables

Once a matching locale has been found, the following sitemap variables will be available to sitemap elements contained within the matcher:

Since:
2.1.6
Version:
$Id: LocaleMatcher.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from interface org.apache.cocoon.matching.Matcher
ROLE
 
Constructor Summary
LocaleMatcher()
           
 
Method Summary
 void configure(Configuration config)
           
 void dispose()
           
 Map match(String pattern, Map objectModel, Parameters parameters)
           
 void service(ServiceManager manager)
           
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleMatcher

public LocaleMatcher()
Method Detail

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException

configure

public void configure(Configuration config)
Specified by:
configure in interface Configurable

dispose

public void dispose()
Specified by:
dispose in interface Disposable

match

public Map match(String pattern,
                 Map objectModel,
                 Parameters parameters)
          throws org.apache.cocoon.sitemap.PatternException
Specified by:
match in interface org.apache.cocoon.matching.Matcher
Throws:
org.apache.cocoon.sitemap.PatternException


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.