play.i18n
Class Lang

java.lang.Object
  extended by play.i18n.Lang

public class Lang
extends java.lang.Object

Language support


Field Summary
static java.lang.ThreadLocal<java.lang.String> current
           
 
Constructor Summary
Lang()
           
 
Method Summary
static void change(java.lang.String locale)
          Change language for next requests
static java.lang.String get()
          Retrieve the current language or null
static void resolvefrom(Http.Request request)
          Guess the language for current request in the following order: if a PLAY_LANG cookie is set, use this value if Accept-Language header is set, use it only if the Play! application allows it.
supported language may be defined in application configuration, eg : play.langs=fr,en,de) otherwise, server's locale language is assumed
static boolean set(java.lang.String locale)
          Force the current language
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

public static java.lang.ThreadLocal<java.lang.String> current
Constructor Detail

Lang

public Lang()
Method Detail

get

public static java.lang.String get()
Retrieve the current language or null

Returns:
The current language (fr, ja, it ...) or null

set

public static boolean set(java.lang.String locale)
Force the current language

Parameters:
locale - (fr, ja, it ...)
Returns:
false if the language is not supported by the application

change

public static void change(java.lang.String locale)
Change language for next requests

Parameters:
locale - (fr, ja, it ...)

resolvefrom

public static void resolvefrom(Http.Request request)
Guess the language for current request in the following order:
  1. if a PLAY_LANG cookie is set, use this value
  2. if Accept-Language header is set, use it only if the Play! application allows it.
    supported language may be defined in application configuration, eg : play.langs=fr,en,de)
  3. otherwise, server's locale language is assumed

Parameters:
request -


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly