Package play.i18n
Class Lang
- Object
-
- play.api.i18n.Lang
-
- play.i18n.Lang
-
- All Implemented Interfaces:
Serializable
,scala.Equals
,scala.Product
public class Lang extends play.api.i18n.Lang
A Lang supported by the application.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<Lang>
availables(Application app)
Retrieve Lang availables from the application configuration.String
code()
The language tag (such as fr or en-US).String
country()
A valid ISO Country Code.static Lang
defaultLang()
The default Lang (platform default).static Lang
forCode(String code)
Create a Lang value from a code (such as fr or en-US).String
language()
A valid ISO Language Code.static Lang
preferred(Application app, List<Lang> availableLangs)
Guess the preferred lang in the langs set passed as argument.String
script()
The script tag for this LangLocale
toLocale()
Convert to a Java Locale value.String
variant()
The variant tag for this Lang-
Methods inherited from class play.api.i18n.Lang
apply, apply, apply, apply$default$2, apply$default$3, apply$default$4, asJava, canEqual, copy, copy$default$1, equals, get, hashCode, jsonOReads, jsonOWrites, jsonTagReads, jsonTagWrites, locale, logger, productArity, productElement, productElementName, productElementNames, productIterator, productPrefix, satisfies, toString, unapply
-
-
-
-
Constructor Detail
-
Lang
public Lang(play.api.i18n.Lang underlyingLang)
-
Lang
public Lang(Locale locale)
-
-
Method Detail
-
language
public String language()
A valid ISO Language Code.- Overrides:
language
in classplay.api.i18n.Lang
-
country
public String country()
A valid ISO Country Code.- Overrides:
country
in classplay.api.i18n.Lang
-
script
public String script()
The script tag for this Lang- Overrides:
script
in classplay.api.i18n.Lang
-
variant
public String variant()
The variant tag for this Lang- Overrides:
variant
in classplay.api.i18n.Lang
-
code
public String code()
The language tag (such as fr or en-US).- Overrides:
code
in classplay.api.i18n.Lang
-
toLocale
public Locale toLocale()
Convert to a Java Locale value.- Overrides:
toLocale
in classplay.api.i18n.Lang
-
forCode
public static Lang forCode(String code)
Create a Lang value from a code (such as fr or en-US).- Parameters:
code
- the language code- Returns:
- the Lang for the code, or null of no matching lang was found.
-
availables
public static List<Lang> availables(Application app)
Retrieve Lang availables from the application configuration.- Parameters:
app
- the current application.- Returns:
- the list of available Lang.
-
preferred
public static Lang preferred(Application app, List<Lang> availableLangs)
Guess the preferred lang in the langs set passed as argument. The first Lang that matches an available Lang wins, otherwise returns the first Lang available in this application.- Parameters:
app
- the current applicationavailableLangs
- the set of langs from which to guess the preferred- Returns:
- the preferred lang.
-
defaultLang
public static Lang defaultLang()
The default Lang (platform default).
-
-