org.bbqjs.spring.debug
Class LanguageController

java.lang.Object
  extended by org.bbqjs.spring.debug.LanguageController

@Controller
public class LanguageController
extends Object

A version of the LanguageController meant for development. Attempts to dynamically create the language file for every request - not recommended for production. Sample Spring configuration:


 <bean id="languageController" class="org.bbqjs.spring.debug.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>
 


Nested Class Summary
static class LanguageController.LanguageRequest
          This class is used to request a given language translation file
 
Constructor Summary
LanguageController()
           
 
Method Summary
 Map<Object,Object> getLanguage(LanguageController.LanguageRequest request, Locale locale)
          The controller method.
protected  Map<Object,Object> getLanguageFile(Object byName, Locale forLocale)
          Compiles and returns a language translation section.
 void setDefaultLocale(Locale defaultLocale)
          When no language translation exists for a given term, fall back to this locale.
 void setPagePackage(String pagePackage)
          The ${js.page.package} from your pom.
 void setSourceRoots(String[] sourceRoots)
          Where to look for language files - a suggested value is "src/main/javascript".
 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
The controller method.

Parameters:
request -
locale -
Returns:
Throws:
IOException

getLanguageFile

protected Map<Object,Object> getLanguageFile(Object byName,
                                             Locale forLocale)
                                      throws IOException
Compiles and returns a language translation section.

Parameters:
byName -
forLocale -
Returns:
Throws:
IOException

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 -

setSourceRoots

public void setSourceRoots(String[] sourceRoots)
Where to look for language files - a suggested value is "src/main/javascript".

Parameters:
sourceRoots -

setPagePackage

public void setPagePackage(String pagePackage)
The ${js.page.package} from your pom. Maven should replace this at run/compile time.

Parameters:
pagePackage -


Copyright © 2012. All Rights Reserved.