Package play.i18n

Class 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
    • 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 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).