info.magnolia.cms.i18n
Class HierarchyBasedI18nContentSupport

java.lang.Object
  extended by info.magnolia.cms.i18n.AbstractI18nContentSupport
      extended by info.magnolia.cms.i18n.HierarchyBasedI18nContentSupport
All Implemented Interfaces:
I18nContentSupport

public class HierarchyBasedI18nContentSupport
extends AbstractI18nContentSupport

Serves i18n content found in a per locale hierarchy structure. E.g.

 +my-website
  + en
   + page-1
   + page-2
   + page-n
  + de
   + page-1
   + page-2
   + page-n
  + de_CH
   + page-1
   + page-2
   + page-n
  + it
   + page-1
   + page-2
   + page-n
The locale is inferred by analyzing the URI and checking whether it contains a valid Java locale code (see definition of valid Java locale code). This code can be at whatever position in the URI, not necessarily the first one. For example, given the following URI /my-website/node-1/node-2/de/home-page.html, the locale de will be detected and content served from here:
 + my-website
  + node-1
   + node-2
    + de
     + home-page
 
Also the last element in the URI, typically a page, can be used to determine the locale. E.g. given the URI /foo/bar/it.html a it locale will be determined. If no locale is found in the URI, the default one is assumed.

Author:
fgrilli

Field Summary
 
Fields inherited from class info.magnolia.cms.i18n.AbstractI18nContentSupport
defaultLocale
 
Constructor Summary
HierarchyBasedI18nContentSupport()
           
 
Method Summary
 NodeData getNodeData(Content node, String name)
          Returns the nodedata with the name <name>_<current language> or <name>_<fallback language> otherwise returns <name>.
protected  Locale onDetermineLocale()
           
protected  String toI18NURI(String uri, Locale locale)
           
protected  String toRawURI(String i18nURI, Locale locale)
           
 
Methods inherited from class info.magnolia.cms.i18n.AbstractI18nContentSupport
addLocale, determineLocale, determineLocalFromString, getDefaultLocale, getFallbackLocale, getLocale, getLocales, getNextContentLocale, getNextLocale, getNodeData, isEmpty, isEnabled, isLocaleSupported, setDefaultLocale, setEnabled, setFallbackLocale, setLocale, toI18NURI, toRawURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchyBasedI18nContentSupport

public HierarchyBasedI18nContentSupport()
Method Detail

onDetermineLocale

protected Locale onDetermineLocale()
Specified by:
onDetermineLocale in class AbstractI18nContentSupport

toI18NURI

protected String toI18NURI(String uri,
                           Locale locale)
Specified by:
toI18NURI in class AbstractI18nContentSupport

toRawURI

protected String toRawURI(String i18nURI,
                          Locale locale)
Specified by:
toRawURI in class AbstractI18nContentSupport

getNodeData

public NodeData getNodeData(Content node,
                            String name)
Description copied from class: AbstractI18nContentSupport
Returns the nodedata with the name <name>_<current language> or <name>_<fallback language> otherwise returns <name>.

Specified by:
getNodeData in interface I18nContentSupport
Overrides:
getNodeData in class AbstractI18nContentSupport


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.