com.atlassian.sal.api.message
Interface I18nResolver


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 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.
 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:- 1) this method returns the i18ned text formatted with the arguments if the key can be resolved.
 

Method Detail

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.

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

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(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:
message - The message to i18n
Returns:
I18ned string

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.

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.

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 © 2010 Atlassian. All Rights Reserved.