public class

I18nBean

extends Object
implements I18nHelper
java.lang.Object
   ↳ com.atlassian.jira.web.bean.I18nBean
Known Direct Subclasses

Class Overview

The standard implementation of I18nHelper. This class should not be instantiated directly but rather obtained indirectly through the I18nHelper.BeanFactory or by simply injecting a I18nHelper directly into your code. In the olden days, there was no I18nHelper and callers would instantiate this class directly. To keep backwards compatibility this class can still be directly created. However, it became very expensive to create an new bean each time (e.g. we have to scan plugins for translations). To combat this, the class was converted into a flyweight that delegates most calls to an I18nHelper obtained through a I18nHelper.BeanFactory. In this way people creating I18nBeans directly will actually be following JIRA's recommended pattern.

Summary

Public Constructors
I18nBean()
I18nBean(Locale locale)
I18nBean(User user)
I18nBean(ApplicationUser user)
I18nBean(I18nHelper delegate)
@Deprecated I18nBean(String localeString)
This constructor is deprecated. use I18nBean(java.util.Locale) instead
Public Methods
ResourceBundle getDefaultResourceBundle()
Returns the default ResourceBundle within JIRA, which does not include translations provided by plugins.
Set<String> getKeysForPrefix(String prefix)
Given a prefix for an i18n key, this method will return all keys that start with the prefix specified.
Locale getLocale()
static Locale getLocaleFromUser(ApplicationUser user)
static Locale getLocaleFromUser(User user)
ResourceBundle getResourceBundle()
Returns the consolidated ResourceBundle for this I18nHelper, which includes translations provided by plugins.
String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, String value1, String value2, String value3, String value4)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, Object value1, Object value2, Object value3, Object value4)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, Object parameters)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found.
String getText(String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, String value9)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, String value1, String value2, String value3)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7, Object value8)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, String value1)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7)
Called to return the formatted text of the specified i18n key
String getText(String key, Object value1, Object value2, Object value3)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getText(String key, String value1, String value2)
Called to return the formatted text of the specified i18n key or the key itself if no message can be found
String getUnescapedText(String key)
Called to return the un-formatted text of the specified i18n key or the key itself if no message can be found
String getUntransformedRawText(String key)
Same as getUnescapedText(String) but does not apply any TranslationTransforms.
boolean isKeyDefined(String key)

For the given key, checks whether such a key is defined in the locale context represented by this helper instance.

Protected Methods
I18nHelper.BeanFactory getFactory()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.util.I18nHelper

Public Constructors

public I18nBean ()

public I18nBean (Locale locale)

public I18nBean (User user)

public I18nBean (ApplicationUser user)

public I18nBean (I18nHelper delegate)

@Deprecated public I18nBean (String localeString)

This constructor is deprecated.
use I18nBean(java.util.Locale) instead

Construct an I18nBean in the given Locale.

Parameters
localeString The locale String. eg "fr_CA"

Public Methods

public ResourceBundle getDefaultResourceBundle ()

Returns the default ResourceBundle within JIRA, which does not include translations provided by plugins. For use cases where non-English translations are required, call getResourceBundle() instead.

Returns
  • a non-null bundle

public Set<String> getKeysForPrefix (String prefix)

Given a prefix for an i18n key, this method will return all keys that start with the prefix specified.

Parameters
prefix The prefix for i18n keys. May not be null
Returns
  • An immutable set of translation keys that start with the prefix specified.

public Locale getLocale ()

public static Locale getLocaleFromUser (ApplicationUser user)

public static Locale getLocaleFromUser (User user)

Parameters
user the user
Returns

public ResourceBundle getResourceBundle ()

Returns the consolidated ResourceBundle for this I18nHelper, which includes translations provided by plugins.

Returns
  • a non-null bundle

public String getText (String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
value6 a value to be substituted into the message
value7 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1, String value2, String value3, String value4)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object value1, Object value2, Object value3, Object value4)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object parameters)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found.

The object passed in can be an array, a List} or a single parameter object. It will be then used as substitution parameters within the message.

Parameters
key the key of the i18n message
parameters This can be an Array, a List and Array or a single object parameter
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, String value9)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
value6 a value to be substituted into the message
value7 a value to be substituted into the message
value8 a value to be substituted into the message
value9 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object value1, Object value2, Object value3, Object value4, Object value5)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
value6 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1, String value2, String value3)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7, Object value8)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
value6 a value to be substituted into the message
value7 a value to be substituted into the message
value8 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7)

Called to return the formatted text of the specified i18n key

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
value4 a value to be substituted into the message
value5 a value to be substituted into the message
value6 a value to be substituted into the message
value7 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, Object value1, Object value2, Object value3)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
value3 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getText (String key, String value1, String value2)

Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
value1 a value to be substituted into the message
value2 a value to be substituted into the message
Returns
  • the formatted text or the key itself if no i18n message can be found

public String getUnescapedText (String key)

Called to return the un-formatted text of the specified i18n key or the key itself if no message can be found

Parameters
key the key of the i18n message
Returns
  • the un-formatted, translated, text or the key itself if no i18n message can be found

public String getUntransformedRawText (String key)

Same as getUnescapedText(String) but does not apply any TranslationTransforms.

Parameters
key the key of the i18n message
Returns
  • the un-formatted text or the key itself if no i18n message can be found

public boolean isKeyDefined (String key)

For the given key, checks whether such a key is defined in the locale context represented by this helper instance. Note that the actual translation may be in the 'fallback' default locale rather than the current locale.

The contract of this is method is correlated with getUntransformedRawText(String), whereby if this method returns false, getUntransformedRawText(String) will return the key provided as an argument, and if this method returns true, getUntransformedRawText(String) will generally return the translation, which in some very unlikely cases may be equal to the key.

Parameters
key translation key
Returns
  • true, if any translation for such key exists, false otherwise

Protected Methods

protected I18nHelper.BeanFactory getFactory ()