Class MessageFormatI18nMessageFormatter

java.lang.Object
org.nuiton.i18n.format.MessageFormatI18nMessageFormatter
All Implemented Interfaces:
I18nMessageFormatter

public class MessageFormatI18nMessageFormatter
extends java.lang.Object
implements I18nMessageFormatter
Implementation of I18nMessageFormatter based on MessageFormat syntax. Note: A formatter will always be used even if there is no parameters in translation. As MessageFormat requires to espece quotes, we need to do this for every translation with or without parameters.
Since:
2.4
See Also:
MessageFormat
  • Constructor Summary

    Constructors 
    Constructor Description
    MessageFormatI18nMessageFormatter()  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String format​(java.util.Locale locale, java.lang.String message, java.lang.Object... args)
    Format a given message with locale and optinal args.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • format

      public java.lang.String format​(java.util.Locale locale, java.lang.String message, java.lang.Object... args)
      Description copied from interface: I18nMessageFormatter
      Format a given message with locale and optinal args. The main purpose is to replace placeholders in message with args value. This may depend on locale for date purpose for example.
      Specified by:
      format in interface I18nMessageFormatter
      Parameters:
      locale - locale to use for formatting (number, date, ...)
      message - message to format (that contains placeholders)
      args - object array to use in formatting the message
      Returns:
      the formatted message