com.atlassian.confluence.util.i18n
Class DefaultI18NBean

java.lang.Object
  extended by com.atlassian.confluence.util.i18n.DefaultI18NBean
All Implemented Interfaces:
I18NBean

public class DefaultI18NBean
extends java.lang.Object
implements I18NBean

Responsible for fetching internationalised text given a key. By default, this will only search the default resource bundle for ConfluenceActionSupport.class

To access i18n keys in resource bundles for other classes: specify these classes in a list (use fully qualified class names)


Field Summary
 
Fields inherited from interface com.atlassian.confluence.util.i18n.I18NBean
DEFAULT_RESOURCE_BUNDLE
 
Constructor Summary
DefaultI18NBean(java.util.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(java.util.Locale locale, com.atlassian.plugin.tracker.PluginModuleTracker<TranslationTransform,TranslationTransformModuleDescriptor> pluginModuleTracker, I18nModeManager modeManager, java.util.List<java.util.ResourceBundle> resourceBundles)
          Deprecated. since 5.2. Don't construct these directly, use DefaultI18NBeanFactory.getI18NBean(java.util.Locale)
 
Method Summary
 java.util.ResourceBundle getResourceBundle()
           
 java.lang.String getText(Message message)
          Gets the i18n text for the specified message, formatting the message's value and arguments with MessageFormat.
 java.lang.String getText(java.lang.String key)
          Get the i18n text for a particular key.
 java.lang.String getText(java.lang.String key, java.util.List list)
           
 java.lang.String getText(java.lang.String key, java.lang.Object[] args)
          Get the i18n text for a particular key, formatted through MessageFormat with the given arguments.
 java.lang.String getTextStrict(java.lang.String i18nKey)
          Needed for text that should not be marked up (for example, values for the 'accessKey' attribute in an input element)
 java.util.Map<java.lang.String,java.lang.String> getTranslationsForPrefix(java.lang.String prefix)
          Gets a map of all keys that start with the given prefix, and their corresponding localised text, suitable for rendering with MessageFormat.
 java.lang.String getUntransformedRawText(java.lang.String key)
          Same as I18NBean.getText(String) but does not apply any TranslationTransforms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultI18NBean

@Deprecated
public DefaultI18NBean(java.util.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

public DefaultI18NBean(java.util.Locale locale,
                       com.atlassian.plugin.tracker.PluginModuleTracker<TranslationTransform,TranslationTransformModuleDescriptor> pluginModuleTracker,
                       I18nModeManager modeManager,
                       java.util.List<java.util.ResourceBundle> resourceBundles)
Deprecated. since 5.2. Don't construct these directly, use DefaultI18NBeanFactory.getI18NBean(java.util.Locale)

Method Detail

getText

public java.lang.String getText(@Nullable
                                java.lang.String key)
Get the i18n text for a particular key.

Specified by:
getText in interface I18NBean

getText

public java.lang.String getText(@Nullable
                                java.lang.String key,
                                @Nullable
                                java.lang.Object[] args)
Get the i18n text for a particular key, formatted through MessageFormat with the given arguments. Works similarly to ActionSupport.getText(String, java.util.List), but the array form is necessary to work well with Velocity.

Specified by:
getText in interface I18NBean
Parameters:
key - the key to retrieve the i18n text for
args - an array of arguments to be passed in to the MessageFormat#format for this text
Returns:
the appropriate i18n text, formatted with the supplied arguments
See Also:
ActionSupport.getText(String, java.util.List), MessageFormat

getUntransformedRawText

public java.lang.String getUntransformedRawText(java.lang.String key)
Description copied from interface: I18NBean
Same as I18NBean.getText(String) but does not apply any TranslationTransforms.

Specified by:
getUntransformedRawText in interface I18NBean
Parameters:
key - the key of the i18n message
Returns:
the un-formatted text or the key itself if no i18n message can be found

getText

public java.lang.String getText(java.lang.String key,
                                java.util.List list)
Specified by:
getText in interface I18NBean

getText

public java.lang.String getText(Message message)
Description copied from interface: I18NBean
Gets the i18n text for the specified message, formatting the message's value and arguments with MessageFormat.

Specified by:
getText in interface I18NBean
Parameters:
message - the message to format, containing an i18n key and arguments
Returns:
the formatted message

getTextStrict

public java.lang.String getTextStrict(java.lang.String i18nKey)
Needed for text that should not be marked up (for example, values for the 'accessKey' attribute in an input element)

Specified by:
getTextStrict in interface I18NBean
Parameters:
i18nKey - the key to retrieve localised text for
Returns:
text for i18nKey (and excludes markup regardless of settings)

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Specified by:
getResourceBundle in interface I18NBean

getTranslationsForPrefix

public java.util.Map<java.lang.String,java.lang.String> getTranslationsForPrefix(java.lang.String prefix)
Description copied from interface: I18NBean
Gets a map of all keys that start with the given prefix, and their corresponding localised text, suitable for rendering with 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).

Specified by:
getTranslationsForPrefix in interface I18NBean


Copyright © 2003-2014 Atlassian. All Rights Reserved.