org.bbqjs.spring.mvc
Class LanguageController

java.lang.Object
  extended by org.bbqjs.spring.mvc.LanguageController
All Implemented Interfaces:
org.springframework.web.context.ServletContextAware

@Controller
public class LanguageController
extends Object
implements org.springframework.web.context.ServletContextAware

Serves maps of language files. This is the non-debug version of org.bbqjs.spring.debug.LanguageController Language files are Java properties files stored under /WEB-INF/language (overrideable by setting the languageFilesLocation property). This class looks up the appropriate file and serves it if available. Sample Spring configuration:


 <bean id="languageController" class="org.bbqjs.spring.mvc.LanguageController">
     <property name="defaultLocale" value="en_GB"/>
     <property name="supportedLocales">
         <list>
             <value>en_GB</value>
             <value>en_US</value>
         </list>
     </property>
     <property name="pagePackage" value="${js.page.package}"/>
     <property name="sourceRoots">
         <list>
             <value>src/main/javascript</value>
         </list>
     </property>
 </bean>
 

See Also:
LanguageController

Nested Class Summary
static class LanguageController.LanguageRequest
           
 
Constructor Summary
LanguageController()
           
 
Method Summary
 Map<Object,Object> getLanguage(LanguageController.LanguageRequest request, Locale locale)
           
protected  Map<Object,Object> getLanguageFile(Object byName, Locale forLocale)
           
 void setDefaultLocale(Locale defaultLocale)
          When no language translation exists for a given term, fall back to this locale.
 void setLanguageFilesLocation(String languageFilesLocation)
          Set this to override where in your application the language files are stored (defaults to /WEB-INF/language)
 void setServletContext(javax.servlet.ServletContext servletContext)
           
 void setSupportedLocales(List<Locale> supportedLocales)
          A list of locales that your application supports.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguageController

public LanguageController()
Method Detail

getLanguage

@RequestMapping(value="/language/get",
                method=POST)
@ResponseBody
public Map<Object,Object> getLanguage(@RequestBody
                                                                  LanguageController.LanguageRequest request,
                                                                  Locale locale)
                               throws IOException
Throws:
IOException

getLanguageFile

protected Map<Object,Object> getLanguageFile(Object byName,
                                             Locale forLocale)
                                      throws IOException
Throws:
IOException

setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Specified by:
setServletContext in interface org.springframework.web.context.ServletContextAware
Parameters:
servletContext -

setLanguageFilesLocation

public void setLanguageFilesLocation(String languageFilesLocation)
Set this to override where in your application the language files are stored (defaults to /WEB-INF/language)

Parameters:
languageFilesLocation -

setSupportedLocales

public void setSupportedLocales(List<Locale> supportedLocales)
A list of locales that your application supports.

Parameters:
supportedLocales -

setDefaultLocale

public void setDefaultLocale(Locale defaultLocale)
When no language translation exists for a given term, fall back to this locale.

Parameters:
defaultLocale -


Copyright © 2012. All Rights Reserved.