< Back
 

# Packages

-  package root
  Definition Classes
    root
-  package uk
  Definition Classes
    root
-  package gov
  Definition Classes
    uk
-  package hmrc
  Definition Classes
    gov
-  package play
  Definition Classes
    hmrc
-  package language
  Definition Classes
    play
- LanguageController
- LanguageUtils

c

uk.gov.hmrc.play.language

# LanguageUtils 

###

#### class LanguageUtils extends AnyRef

This object provides access to common language utilities.

This object contains language codes for English and Welsh and a function to return the current language based on a request header.

Additionally, a Dates object is provided which provides helper functions to return correctly formatted dates in both English and Welsh.

Linear Supertypes
AnyRef, Any
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. LanguageUtils
2. AnyRef
3. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new LanguageUtils(langs: Langs, configuration: Configuration)(implicit messagesApi: MessagesApi)
   Annotations
     @Inject()

### Type Members

1.  trait Dates extends AnyRef

   A trait that correctly displays and formats dates in multiple languages.

   A trait that correctly displays and formats dates in multiple languages.

   This object contains helper methods to correctly format dates in any language supported by the IBM ICU library.

   This trait requires a default timezone to be defined, as well as String values for the English words: - to - day - days

   These values should come from a Messages file for each language that needs to be supported.

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##(): Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
5.  def clone(): AnyRef
   Attributes
     protected[lang]
   Definition Classes
     AnyRef
   Annotations
     @throws( ... ) @native()
6.  final def eq(arg0: AnyRef): Boolean
   Definition Classes
     AnyRef
7.  def equals(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
8.  def finalize(): Unit
   Attributes
     protected[lang]
   Definition Classes
     AnyRef
   Annotations
     @throws( classOf[java.lang.Throwable] )
9.  final def getClass(): Class[_]
   Definition Classes
     AnyRef → Any
   Annotations
     @native()
10.  def getCurrentLang(implicit request: RequestHeader): Lang

    Returns the current language as a Lang object.

    Returns the current language as a Lang object.

    This function returns the current language as an i18n Lang object. It first checks that the PLAY_LANG cookie exists from the request object and then gets the value from it. If it does not exist then it returns the accepted language from the request object. If there is no Play application then it just defaults to return the accepted language in the request or use the default language.

    request

      The RequestHeader object to extract the language information from.

    returns

      Lang object containing the current langugage.

11.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
12.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
13.  def isLangAvailable(lang: Lang): Boolean

    Returns true if the lang passed exists within `play.i18n.langs` config value

    Returns true if the lang passed exists within `play.i18n.langs` config value

    lang

      The language to check against

    returns

      A boolean on wether this language is supported in the current application

14.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
15.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
16.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
17.  def onlyAvailableLanguages(langMap: Map[String, Lang]): Map[String, Lang]

    Filters a Map of languages against what languages are enabled in the current application

    Filters a Map of languages against what languages are enabled in the current application

    This function returns a filtered Map containing only languages which are enabled in the `play.i18n.langs` configuration value. This function is to be used to dynamically populate which languages should be displayed on the applications language switcher.

    langMap

      List of all supported languages

    returns

      filtered list of enabled languages

18.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
19.  def toString(): String
    Definition Classes
      AnyRef → Any
20.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
21.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
22.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... ) @native()
23.  object Dates extends Dates

    Helper object to correctly display and format dates in both English and Welsh.

    Helper object to correctly display and format dates in both English and Welsh.

    This object provides a default implementation of the Dates trait in order to provide support for Welsh and English dates.

### Inherited from AnyRef

### Inherited from Any

### Ungrouped