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.
- Alphabetic
- By Inheritance
- LanguageUtils
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
LanguageUtils(langs: Langs, configuration: Configuration)(implicit messagesApi: MessagesApi)
- Annotations
- @Inject()
Type Members
-
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
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
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.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isLangAvailable(lang: Lang): Boolean
Returns true if the lang passed exists within
play.i18n.langsconfig valueReturns true if the lang passed exists within
play.i18n.langsconfig value- lang
The language to check against
- returns
A boolean on wether this language is supported in the current application
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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.langsconfiguration 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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
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.