com.atlassian.sal.api.message
Interface I18nResolver

All Known Implementing Classes:
AbstractI18nResolver

public interface I18nResolver

This interface is responsible for resolving a message or key/argument pairs to their internationalized message.

Since:
2.0

Method Summary
 Message createMessage(String key, Serializable... arguments)
          Creates an instance of Message.
 MessageCollection createMessageCollection()
           
 Map<String,String> getAllTranslationsForPrefix(String prefix)
          Given a prefix, this method will return all translations where the key starts with the given prefix as key -> value mappings, using the default locale.
 Map<String,String> getAllTranslationsForPrefix(String prefix, Locale locale)
          Given a prefix, this method will return all translations where the key starts with the given prefix as key -> value mappings.
 String getRawText(String key)
          Retrieve the unformatted message text associated with this key.
 String getText(Locale locale, Message message)
          Given a Message this method: returns the i18ned text formatted with the message arguments if the message key can be resolved. Otherwise, returns the message key (formatted with the message arguments).
 String getText(Locale locale, String key)
          Does the same as getText(Locale, String, java.io.Serializable...) however it is needed for velocity.
 String getText(Locale locale, String key, Serializable... arguments)
          Given a key and a list of arguments: this method returns the i18ned text formatted with the arguments if the key can be resolved. otherwise, the key itself will be returned (after formatting). Arguments may also be of the form Message which means they will be resolved as well before being included as an argument.
 String getText(Message message)
          Given a Message this method: returns the i18ned text formatted with the message arguments if the message key can be resolved. Otherwise, returns the message key (formatted with the message arguments). Uses the default locale.
 String getText(String key)
          Does the same as getText(String, java.io.Serializable...) however it is needed for velocity.
 String getText(String key, Serializable... arguments)
          Given a key and a list of arguments: this method returns the i18ned text formatted with the arguments if the key can be resolved. otherwise, the key itself will be returned (after formatting). Arguments may also be of the form Message which means they will be resolved as well before being included as an argument.
 

Method Detail

getRawText

String getRawText(String key)
Retrieve the unformatted message text associated with this key.

Parameters:
key - key for the i18ned message
Returns:
the unformatted message text if key is found, otherwise returns key itself.

getText

String getText(String key,
               Serializable... arguments)
Given a key and a list of arguments:
  1. this method returns the i18ned text formatted with the arguments if the key can be resolved.
  2. otherwise, the key itself will be returned (after formatting).
Arguments may also be of the form Message which means they will be resolved as well before being included as an argument. Uses the default locale.

Parameters:
key - key for the i18ned message
arguments - Optional list of arguments for the message.
Returns:
I18ned string

getText

String getText(Locale locale,
               String key,
               Serializable... arguments)
Given a key and a list of arguments:
  1. this method returns the i18ned text formatted with the arguments if the key can be resolved.
  2. otherwise, the key itself will be returned (after formatting).
Arguments may also be of the form Message which means they will be resolved as well before being included as an argument.

Parameters:
locale - the locale to use for the i18ned text
key - key for the i18ned message
arguments - Optional list of arguments for the message.
Returns:
I18ned string
Since:
2.10

getText

String getText(String key)
Does the same as getText(String, java.io.Serializable...) however it is needed for velocity.

Parameters:
key - key for the i18ned message
Returns:
I18ned string

getText

String getText(Locale locale,
               String key)
Does the same as getText(Locale, String, java.io.Serializable...) however it is needed for velocity.

Parameters:
locale - the locale to use for the i18ned text
key - key for the i18ned message
Returns:
I18ned string
Since:
2.10

getText

String getText(Message message)
Given a Message this method:
  1. returns the i18ned text formatted with the message arguments if the message key can be resolved.
  2. Otherwise, returns the message key (formatted with the message arguments).
Uses the default locale.

Parameters:
message - The message to i18n
Returns:
I18ned string

getText

String getText(Locale locale,
               Message message)
Given a Message this method:
  1. returns the i18ned text formatted with the message arguments if the message key can be resolved.
  2. Otherwise, returns the message key (formatted with the message arguments).

Parameters:
locale - the locale to use for the i18ned text
message - The message to i18n
Returns:
I18ned string
Since:
2.10

createMessage

Message createMessage(String key,
                      Serializable... arguments)
Creates an instance of Message.

Parameters:
key - The message key
arguments - The arguments to interpolate
Returns:
The message

createMessageCollection

MessageCollection createMessageCollection()
Returns:
an instance of MessageCollection.

getAllTranslationsForPrefix

Map<String,String> getAllTranslationsForPrefix(String prefix)
Given a prefix, this method will return all translations where the key starts with the given prefix as key -> value mappings, using the default locale.

Plugin developers should avoid calling this method where possible, as it cannot guarantee as good performance as the other exact key-oriented methods in this interface.

Parameters:
prefix - The prefix for a particular key to start with. Empty string will match everything, which may be slow. Throws NullPointerException if null.
Returns:
A Map of i18nKey -> translation mappings where i18nKey starts with the prefix. Empty map if no matches.
Throws:
NullPointerException - if link is null
Since:
2.1

getAllTranslationsForPrefix

Map<String,String> getAllTranslationsForPrefix(String prefix,
                                               Locale locale)
Given a prefix, this method will return all translations where the key starts with the given prefix as key -> value mappings.

Plugin developers should avoid calling this method where possible, as it cannot guarantee as good performance as the other exact key-oriented methods in this interface.

Parameters:
prefix - The prefix for a particular key to start with. Empty string will match everything, which may be slow. Throws NullPointerException if null.
locale - The locale for which to lookup translations. Throws NullPointerException if null.
Returns:
A Map of i18nKey -> translation mappings where i18nKey starts with the prefix. Empty map if no matches.
Throws:
NullPointerException - if prefix or link are null


Copyright © 2015 Atlassian. All rights reserved.