public class DefaultI18NBean extends Object implements I18NBean
To access i18n keys in resource bundles for other classes: specify these classes in a list (use fully qualified class names)
DEFAULT_RESOURCE_BUNDLE
Constructor and Description |
---|
DefaultI18NBean(Locale locale,
com.atlassian.plugin.PluginAccessor pluginAccessor,
I18nModeManager modeManager)
Deprecated.
since 5.2. Don't construct these directly, use
DefaultI18NBeanFactory.getI18NBean(java.util.Locale) |
DefaultI18NBean(Locale locale,
com.atlassian.plugin.tracker.PluginModuleTracker<TranslationTransform,TranslationTransformModuleDescriptor> pluginModuleTracker,
I18nModeManager modeManager,
List<ResourceBundle> resourceBundles)
Deprecated.
since 5.2. Don't construct these directly, use
DefaultI18NBeanFactory.getI18NBean(java.util.Locale) |
Modifier and Type | Method and Description |
---|---|
ResourceBundle |
getResourceBundle() |
String |
getText(Message message)
Gets the i18n text for the specified message, formatting the message's value and arguments with
MessageFormat . |
String |
getText(@Nullable String key)
Get the i18n text for a particular key.
|
String |
getText(String key,
List list) |
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(String key,
Object[] args,
boolean onlyRawValue)
Get the i18n text for a particular key, formatted through MessageFormat with the given arguments.
|
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 with
MessageFormat . |
String |
getUntransformedRawText(String key)
Same as
I18NBean.getText(String) but does not apply any TranslationTransform s. |
@Deprecated public DefaultI18NBean(Locale locale, com.atlassian.plugin.PluginAccessor pluginAccessor, I18nModeManager modeManager)
DefaultI18NBeanFactory.getI18NBean(java.util.Locale)
@Deprecated public DefaultI18NBean(Locale locale, com.atlassian.plugin.tracker.PluginModuleTracker<TranslationTransform,TranslationTransformModuleDescriptor> pluginModuleTracker, I18nModeManager modeManager, List<ResourceBundle> resourceBundles)
DefaultI18NBeanFactory.getI18NBean(java.util.Locale)
public String getText(@Nullable String key, @Nullable Object[] args)
ActionSupport.getText(String, java.util.List)
, but the array form is necessary to work well
with Velocity.getText
in interface I18NBean
key
- the key to retrieve the i18n text forargs
- an array of arguments to be passed in to the MessageFormat#format for this textActionSupport.getText(String, java.util.List)
,
MessageFormat
public String getText(String key, Object[] args, boolean onlyRawValue)
ActionSupport.getText(String, java.util.List)
, but the array form is necessary to work well
with Velocity.getText
in interface I18NBean
key
- the key to retrieve the i18n text forargs
- an array of arguments to be passed in to the MessageFormat#format for this textonlyRawValue
- identify the need of processing the value of the key, like escape and formatActionSupport.getText(String, java.util.List)
,
MessageFormat
public String getUntransformedRawText(String key)
I18NBean
I18NBean.getText(String)
but does not apply any TranslationTransform
s.getUntransformedRawText
in interface I18NBean
key
- the key of the i18n messagepublic String getText(Message message)
I18NBean
MessageFormat
.public String getTextStrict(String i18nKey)
getTextStrict
in interface I18NBean
i18nKey
- the key to retrieve localised text forpublic ResourceBundle getResourceBundle()
getResourceBundle
in interface I18NBean
public Map<String,String> getTranslationsForPrefix(String prefix)
I18NBean
MessageFormat
.
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).getTranslationsForPrefix
in interface I18NBean
Copyright © 2003–2020 Atlassian. All rights reserved.