org.sonar.api.i18n
Interface I18n

All Superinterfaces:
BatchComponent, ServerComponent

public interface I18n
extends ServerComponent, BatchComponent

Main component that provides translation facilities.

Since:
2.10

Method Summary
 String age(Locale locale, Date fromDate, Date toDate)
          Return the distance in time between two dates.
 String age(Locale locale, long durationInMillis)
          Return the distance in time for a duration in milliseconds.
 String ageFromNow(Locale locale, Date date)
          Reports the distance in time a date and now.
 String formatDate(Locale locale, Date date)
          Return the formatted date.
 String formatDateTime(Locale locale, Date date)
          Return the formatted datetime.
 String formatDouble(Locale locale, Double value)
          Return the formatted decimal, with always one fraction digit.
 String formatInteger(Locale locale, Integer value)
          Return the formatted integer.
 String message(Locale locale, String key, String defaultValue, Object... parameters)
          Searches the message of the key for the locale in the list of available bundles.
 

Method Detail

message

String message(Locale locale,
               String key,
               @Nullable
               String defaultValue,
               Object... parameters)
Searches the message of the key for the locale in the list of available bundles.
If not found in any bundle, defaultValue is returned.

If additional parameters are given (in the objects list), the result is used as a message pattern to use in a MessageFormat object along with the given parameters.

Parameters:
locale - the locale to translate into
key - the key of the pattern to translate
defaultValue - the default pattern returned when the key is not found in any bundle
parameters - the parameters used to format the message from the translated pattern.
Returns:
the message formatted with the translated pattern and the given parameters

age

String age(Locale locale,
           long durationInMillis)
Return the distance in time for a duration in milliseconds.
Examples :

Since:
4.2

age

String age(Locale locale,
           Date fromDate,
           Date toDate)
Return the distance in time between two dates.

Since:
4.2
See Also:
age(java.util.Locale, long durationInMillis)

ageFromNow

String ageFromNow(Locale locale,
                  Date date)
Reports the distance in time a date and now.

Since:
4.2
See Also:
age(java.util.Locale, java.util.Date, java.util.Date)

formatDateTime

String formatDateTime(Locale locale,
                      Date date)
Return the formatted datetime.
Example : formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22T19:10:03+0100")) -> Jan 22, 2014 7:10 PM

Since:
4.2

formatDate

String formatDate(Locale locale,
                  Date date)
Return the formatted date.
Example : formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22")) -> Jan 22, 2014

Since:
4.2

formatDouble

String formatDouble(Locale locale,
                    Double value)
Return the formatted decimal, with always one fraction digit.
Example : formatDouble(Locale.FRENCH, 10.56) -> 10,6

Since:
4.4

formatInteger

String formatInteger(Locale locale,
                     Integer value)
Return the formatted integer.
Example : formatInteger(Locale.ENGLISH, 100000) -> 100,000

Since:
4.4


Copyright © 2009–2015 SonarSource. All rights reserved.