Package play.i18n

Class Lang

java.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:
  • Field Summary

    Fields inherited from class play.api.i18n.Lang

    OFFSET$_m_0, OFFSET$0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Lang(Locale locale)
     
    Lang(play.api.i18n.Lang underlyingLang)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Lang>
    Retrieve Lang availables from the application configuration.
    The language tag (such as fr or en-US).
    A valid ISO Country Code.
    static Lang
    The default Lang (platform default).
    static Lang
    Create a Lang value from a code (such as fr or en-US).
    A valid ISO Language Code.
    static Lang
    preferred(Application app, List<Lang> availableLangs)
    Guess the preferred lang in the langs set passed as argument.
    The script tag for this Lang
    Convert to a Java Locale value.
    The variant tag for this Lang

    Methods inherited from class play.api.i18n.Lang

    _1, apply, apply, apply, apply$default$2, apply$default$3, apply$default$4, asJava, canEqual, copy, copy$default$1, equals, fromProduct, get, hashCode, jsonOReads, jsonOWrites, jsonTagReads, jsonTagWrites, locale, logger, productArity, productElement, productElementName, productPrefix, satisfies, toString, unapply

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface scala.Product

    productElementNames, productIterator
  • Constructor Details

    • Lang

      public Lang(play.api.i18n.Lang underlyingLang)
    • Lang

      public Lang(Locale locale)
  • Method Details

    • language

      public String language()
      A valid ISO Language Code.
      Overrides:
      language in class play.api.i18n.Lang
    • country

      public String country()
      A valid ISO Country Code.
      Overrides:
      country in class play.api.i18n.Lang
    • script

      public String script()
      The script tag for this Lang
      Overrides:
      script in class play.api.i18n.Lang
    • variant

      public String variant()
      The variant tag for this Lang
      Overrides:
      variant in class play.api.i18n.Lang
    • code

      public String code()
      The language tag (such as fr or en-US).
      Overrides:
      code in class play.api.i18n.Lang
    • toLocale

      public Locale toLocale()
      Convert to a Java Locale value.
      Overrides:
      toLocale in class play.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 application
      availableLangs - the set of langs from which to guess the preferred
      Returns:
      the preferred lang.
    • defaultLang

      public static Lang defaultLang()
      The default Lang (platform default).