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
  • class LanguageUtils extends AnyRef

    This object provides access to common language utilities.

    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.

    Definition Classes
    language
  • Dates

trait Dates extends AnyRef

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.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Dates
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def defaultTimeZone: TimeZone

    The timezone to use when formatting dates

  2. abstract def plural(implicit messages: Messages): String

    The value of the plural of the word 'day' *

  3. abstract def singular(implicit messages: Messages): String

    The value of the singular of the word 'day' *

  4. abstract def to(implicit messages: Messages): String

    The value of the word 'to' *

Concrete 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(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def formatDate(date: Option[LocalDate], default: String)(implicit messages: Messages): String

    Converts an Option java.time.LocalDate object into a String with the format "D MMMM Y"

    Converts an Option java.time.LocalDate object into a String with the format "D MMMM Y"

    This function will return a translated string based on the implicit lang object that is passed through with it. If the option is None then the default value is returned back to the caller.

    Lang("en") example: 25 January 2015 Lang("cy") example: 25 Ionawr 2015 None example: default

    date

    The Optional java.time.LocalDate object to convert.

    default

    A default value to return if the date option is not set.

    messages

    The implicit lang object.

    returns

    Either the date as a "D MMMM Y" formatted string or the default value if not set.

  9. def formatDate(date: LocalDate)(implicit messages: Messages): String

    Converts a java.time.LocalDate object into a String with the format "D MMMM Y".

    Converts a java.time.LocalDate object into a String with the format "D MMMM Y".

    This function will return a translated string based on the implicit lang object that is passed through with it.

    Lang("en") example: 25 January 2015 Lang("cy") example: 25 Ionawr 2015

    date

    The java.time.LocalDate object to convert.

    messages

    The implicit lang object.

    returns

    The date as a "D MMMM Y" formatted string.

  10. def formatDateAbbrMonth(date: LocalDate)(implicit messages: Messages): String

    Converts a java.time.LocalDate object into a human readable String with the format "D MMM Y"

    Converts a java.time.LocalDate object into a human readable String with the format "D MMM Y"

    This function will return a translated string based on the implicit lang object that is passed through with it.

    Lang("en") example: 25 Jan 2015 Lang("cy") example: 25 Ion 2015

    date

    The java.time.LocalDate object to convert.

    messages

    The implicit lang object.

    returns

    The date as a "D MMM Y" formatted string.

  11. def formatDateRange(startDate: LocalDate, endDate: LocalDate)(implicit messages: Messages): String

    Converts two java.time.LocalDate objects into a human readable String to show a date range.

    Converts two java.time.LocalDate objects into a human readable String to show a date range.

    This function will return a translated string based on the implicit lang object.

    Lang("en") example: "25 January 2015 to 25 January 2015" Lang("cy") example: "25 Ionawr 2015 i 25 Ionawr 2015"

    startDate

    The first date.

    endDate

    The second date.

    messages

    The implicit lang value.

    returns

    A string in the format of "D MMMM Y to D MMMM Y"

  12. def formatDays(numberOfDays: Int)(implicit messages: Messages): String

    Converts an Int into a string appended by 'days'.

    Converts an Int into a string appended by 'days'.

    This function will return a translated string based on the implicit lang object. It checks to see if the number of days is equal to 1 or not, and then responds with the correct plural or singular value for the word "day".

    1, Lang("en") example: 1 day 5, Lang("en") example: 5 days

    numberOfDays

    - The number of days.

    messages

    - The implicit language object.

    returns

    A string denoting "x" days.

  13. def formatEasyReadingTimestamp(date: Option[LocalDateTime], default: String)(implicit messages: Messages): String

    Converts an optional DateTime object into a human readable String with the format: "h:mmaa, EEEE d MMMM yyyy"

    Converts an optional DateTime object into a human readable String with the format: "h:mmaa, EEEE d MMMM yyyy"

    This function will return a translated string based on the implicit lang object that is passed through with it. If the option is None then the default value is returned back to the caller.

    Lang("en") example: "3:45am, Sunday 25 January 2015" Lang("cy" example: "3:45am, Dydd Sul 25 Ionawr 2015"

    date

    The optional java.time.LocalDateTime object to convert.

    default

    The default value to return if the date is missing.

    messages

    The implicit lang object.

    returns

    The date and time as a "h:mmaa, EEEE d MMMM yyyy" formatted string.

  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. def shortDate(date: LocalDate)(implicit messages: Messages): String

    Converts a java.time.LocalDate object into a human readable String with the format: "yyyy-MM-dd"

    Converts a java.time.LocalDate object into a human readable String with the format: "yyyy-MM-dd"

    This function will return a translated string based on the implicit lang object that is passed through with it.

    Lang("en") example: 2015-01-25 Lang("cy") example: 2015-01-25

    date

    - The java.time.LocalDate object to be converted.

    messages

    - The implicit language object.

    returns

    The date as a "yyyy-MM-dd" formatted string.

  21. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  22. def toString(): String
    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped