Interface I18NBean
-
- All Known Implementing Classes:
DefaultI18NBean
public interface I18NBean
Responsible for fetching internationalised text for a given key.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_RESOURCE_BUNDLE
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ResourceBundle
getResourceBundle()
String
getText(@Nullable String key)
Get the i18n text for a particular key.String
getText(@Nullable String key, @Nullable Object[] args)
Get the i18n text for a particular key, formatted through MessageFormat with the given arguments.String
getText(@Nullable String key, @Nullable List list)
String
getText(Message message)
Gets the i18n text for the specified message, formatting the message's value and arguments withMessageFormat
.default String
getText(String key, Object[] args, boolean onlyRawValue)
String
getTextStrict(String i18nKey)
Needed for text that should not be marked up (for example, values for the 'accessKey' attribute in an input element)Map<String,String>
getTranslationsForPrefix(String prefix)
Gets a map of all keys that start with the given prefix, and their corresponding localised text, suitable for rendering withMessageFormat
.String
getUntransformedRawText(String key)
Same asgetText(String)
but does not apply anyTranslationTransform
s.
-
-
-
Field Detail
-
DEFAULT_RESOURCE_BUNDLE
static final String DEFAULT_RESOURCE_BUNDLE
-
-
Method Detail
-
getText
String getText(@Nullable String key, @Nullable Object[] args)
Get the i18n text for a particular key, formatted through MessageFormat with the given arguments. Works similarly toActionSupport.getText(String, java.util.List)
, but the array form is necessary to work well with Velocity.- Parameters:
key
- the key to retrieve the i18n text forargs
- an array of arguments to be passed in to theMessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
for this text- Returns:
- the appropriate i18n text, formatted with the supplied arguments
- See Also:
ActionSupport.getText(String, java.util.List)
,MessageFormat
-
getText
String getText(Message message)
Gets the i18n text for the specified message, formatting the message's value and arguments withMessageFormat
.- Parameters:
message
- the message to format, containing an i18n key and arguments- Returns:
- the formatted message
-
getTextStrict
String getTextStrict(String i18nKey)
Needed for text that should not be marked up (for example, values for the 'accessKey' attribute in an input element)- Parameters:
i18nKey
- the key to retrieve localised text for- Returns:
- text for i18nKey (and excludes markup regardless of settings)
-
getResourceBundle
ResourceBundle getResourceBundle()
-
getTranslationsForPrefix
Map<String,String> getTranslationsForPrefix(String prefix)
Gets a map of all keys that start with the given prefix, and their corresponding localised text, suitable for rendering withMessageFormat
. It is strongly recommended that plugin developers not use this, as its performance is not guaranteed. Instead, apply translations for specific keys (e.g. via the jsI18n web resource transformer).- Since:
- 5.0
-
getUntransformedRawText
String getUntransformedRawText(String key)
Same asgetText(String)
but does not apply anyTranslationTransform
s.- Parameters:
key
- the key of the i18n message- Returns:
- the un-formatted text or the key itself if no i18n message can be found
-
-