Packages

package i18n

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. final case class KeyLocale(key: Key, locale: Locale) extends Product with Serializable
  2. class Messages extends Logging

    Internationalization (i18n) and localization (l10n) helper class.

    Internationalization (i18n) and localization (l10n) helper class.

    Message files (located in resources/i18n/, by default) are written using Typesafe Config "HOCON" format. HOCON fully supports UTF-8 Unicode and is more flexible and powerful than Java .properties.

    For instance, it is possible to have a locale such as "en-CA" to automatically default to another locale, say "en", if a message is missing: just add the include "messages.en.conf" line to the messages.en-CA.conf file.

    Messages are rendered by ICU4J, which provides comprehensive support for Unicode, globalization, and internationalization. Compared to Java MessageFormat, ICU4J supports named and numbered arguments, enhanced gender and plurals, user-friendly apostrophe quoting syntax, cardinal (one, two) and ordinal numbers (1st, 2nd, 3rd), and much more.

    Examples:
    1. @i18n object messages
      
      implicit val defaultLocale = Locale.ENGLISH
      val ptBr = Locale.forLanguageTag("pt-BR")
      
      assert(messages.helloWorld == "Hello World!")
      assert(messages.helloWorld(ptBr) == "Oi Mundo!")

      Formatted messages are also supported:

    2. ,
    3. assert(messages.hello(name = "Scail") == "Hello Scail!")
      assert(messages.hello(name = "Scail")(ptBr) == "Oi Scail!")

      One can pass custom parameters to the annotation by extending the Messages class:

    4. ,
    5. @i18n object messages extends Messages(filename = "sample")

      Please notice that parameter order in the method follows the same order as they were specified in the messages file. Therefore, it is highly recommended to use named parameters exclusively, as changes in the messages file can easily change parameter names or their relative order. Parameter types are inferred as java.util.Date if a date format is used in the messages file, as java.lang.Number if a number format is used, and Any otherwise.

    See also

    MessageFormat

    PluralFormat

    SelectFormat Optionally, one may use the @i18n macro annotation for classes and objects. The @i18n macro reads the messages file at compile time and generates typesafe methods for every localized message.

  3. class i18n extends Annotation with StaticAnnotation

    Annotations
    @SuppressWarnings() @compileTimeOnly( ... )
    See also

    scail.commons.i18n.Messages

  4. class i18nMacro extends AnyRef

    Annotations
    @SuppressWarnings()
    See also

    scail.commons.i18n.Messages

Value Members

  1. object Messages

Ungrouped