Package 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
Modifier and TypeMethodDescriptioncreateMessage(String key, Serializable... arguments) Creates an instance of Message.getAllTranslationsForPrefix(String prefix) Given a prefix, this method will return all translations where the key starts with the given prefix as key to value mappings, using the default locale.getAllTranslationsForPrefix(String prefix, Locale locale) Given a prefix, this method will return all translations where the key starts with the given prefix as key to value mappings.getRawText(String key) Retrieve the unformatted message text associated with this key.getRawText(Locale locale, String key) Retrieve the unformatted message text associated with this key.Given aMessagethis 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.Does the same asgetText(String, java.io.Serializable...)however it is needed for velocity.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 formMessagewhich means they will be resolved as well before being included as an argument.Given aMessagethis 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).Does the same asgetText(Locale, String, java.io.Serializable...)however it is needed for velocity.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 formMessagewhich means they will be resolved as well before being included as an argument.
-
Method Details
-
getRawText
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.
-
getRawText
Retrieve the unformatted message text associated with this key.- Parameters:
locale- the locale to use for the i18ned textkey- key for the i18ned message- Returns:
- the unformatted message text if key is found, otherwise returns key itself.
-
getText
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).
Messagewhich means they will be resolved as well before being included as an argument. Uses the default locale.- Parameters:
key- key for the i18ned messagearguments- Optional list of arguments for the message.- Returns:
- I18ned string
-
getText
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).
Messagewhich means they will be resolved as well before being included as an argument.- Parameters:
locale- the locale to use for the i18ned textkey- key for the i18ned messagearguments- Optional list of arguments for the message.- Returns:
- I18ned string
- Since:
- 2.10
-
getText
Does the same asgetText(String, java.io.Serializable...)however it is needed for velocity.- Parameters:
key- key for the i18ned message- Returns:
- I18ned string
-
getText
Does the same asgetText(Locale, String, java.io.Serializable...)however it is needed for velocity.- Parameters:
locale- the locale to use for the i18ned textkey- key for the i18ned message- Returns:
- I18ned string
- Since:
- 2.10
-
getText
Given aMessagethis 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).
- Parameters:
message- The message to i18n- Returns:
- I18ned string
-
getText
Given aMessagethis 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).
- Parameters:
locale- the locale to use for the i18ned textmessage- The message to i18n- Returns:
- I18ned string
- Since:
- 2.10
-
createMessage
Creates an instance of Message.- Parameters:
key- The message keyarguments- The arguments to interpolate- Returns:
- The message
-
createMessageCollection
MessageCollection createMessageCollection()- Returns:
- an instance of MessageCollection.
-
getAllTranslationsForPrefix
Given a prefix, this method will return all translations where the key starts with the given prefix as key to 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. ThrowsNullPointerExceptionifnull.- Returns:
- A Map of i18nKey to translation mappings where i18nKey starts with the prefix. Empty map if no matches.
- Throws:
NullPointerException- iflinkisnull- Since:
- 2.1
-
getAllTranslationsForPrefix
Given a prefix, this method will return all translations where the key starts with the given prefix as key to 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. ThrowsNullPointerExceptionifnull.locale- The locale for which to lookup translations. ThrowsNullPointerExceptionifnull.- Returns:
- A Map of i18nKey to translation mappings where i18nKey starts with the prefix. Empty map if no matches.
- Throws:
NullPointerException- ifprefixorlinkarenull
-