|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.web.bean.BackingI18n
@Immutable @Internal public class BackingI18n
DEVSPEED-34: We wanted to properly cache the I18nBean. To make that happen we turned the I18nBean into a flyweight during JIRA 4.3. All of the original logic was moved into this class.
Looking up translations in plugins happens lazily. This (shouldn't) have any real world impact but it makes certain unit tests easier. (You don't need to worry about mocking out PluginAccessor.) Note that this class is cached by theI18nBean.CachingFactory
per Locale and will
be re-created during plugin reload events.
http://en.wikipedia.org/wiki/Flyweight_pattern
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.atlassian.jira.util.I18nHelper |
---|
I18nHelper.BeanFactory |
Constructor Summary | |
---|---|
BackingI18n(Locale locale,
I18nTranslationMode i18nTranslationMode,
InvolvedPluginsTracker involvedPluginsTracker,
List<TranslationTransform> translationTransforms)
Construct an I18nBean in the given Locale. |
Method Summary | |
---|---|
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()
|
protected com.atlassian.plugin.PluginAccessor |
getPluginAccessor()
Subclasses should override this and return null if they don't want to touch the ComponentManager |
ResourceBundle |
getResourceBundle()
Returns the ResourceBundle for this I18nHelper. |
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 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,
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,
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 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,
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,
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)
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,
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,
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,
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 |
getUnescapedText(String key)
Get the raw property value, complete with {0}'s. |
String |
getUntransformedRawText(String key)
Same as I18nHelper.getUnescapedText(String) but does not apply any TranslationTransform s. |
boolean |
isKeyDefined(String key)
For the given key, checks whether such a key is defined in the locale context represented by this helper instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BackingI18n(Locale locale, I18nTranslationMode i18nTranslationMode, InvolvedPluginsTracker involvedPluginsTracker, List<TranslationTransform> translationTransforms)
locale
- the Localei18nTranslationMode
- whether the magic translate mode is on or notinvolvedPluginsTracker
- keeps track of which plugins have I18N information
so that we can avoid flushing the translation cache when unrelated modulestranslationTransforms
- a list of active translation transforms to applyMethod Detail |
---|
public Locale getLocale()
getLocale
in interface I18nHelper
Locale
that is associated with this I18nHelperpublic ResourceBundle getDefaultResourceBundle()
I18nHelper
ResourceBundle
within JIRA, which does not include translations provided by plugins.
For use cases where non-English translations are required, call I18nHelper.getResourceBundle()
instead.
getDefaultResourceBundle
in interface I18nHelper
I18nHelper.getResourceBundle()
protected com.atlassian.plugin.PluginAccessor getPluginAccessor()
PluginAccessor
if its null then plugin resource loading wont happenpublic Set<String> getKeysForPrefix(String prefix)
I18nHelper
getKeysForPrefix
in interface I18nHelper
prefix
- The prefix for i18n keys. May not be null
public String getUnescapedText(String key)
getUnescapedText
in interface I18nHelper
key
- Non-null key to look up
public String getUntransformedRawText(String key)
I18nHelper
I18nHelper.getUnescapedText(String)
but does not apply any TranslationTransform
s.
getUntransformedRawText
in interface I18nHelper
key
- the key of the i18n message
public boolean isKeyDefined(String key)
I18nHelper
I18nHelper.getUntransformedRawText(String)
, whereby if this
method returns false
, I18nHelper.getUntransformedRawText(String)
will return the key provided as an
argument, and if this method returns true
, I18nHelper.getUntransformedRawText(String)
will generally
return the translation, which in some very unlikely cases may be equal to the key.
isKeyDefined
in interface I18nHelper
key
- translation key
true
, if any translation for such key exists, false
otherwisepublic String getText(String key)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n message
public String getText(String key, String value1)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the message
public String getText(String key, String value1, String value2)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the message
public String getText(String key, String value1, String value2, String value3)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the message
public String getText(String key, String value1, String value2, String value3, String value4)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3, Object value4)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the messagevalue6
- a value to be substituted into the message
public String getText(String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the messagevalue6
- a value to be substituted into the messagevalue7
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the messagevalue6
- a value to be substituted into the messagevalue7
- a value to be substituted into the message
public String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7, Object value8)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the messagevalue6
- a value to be substituted into the messagevalue7
- a value to be substituted into the messagevalue8
- a value to be substituted into the message
public String getText(String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, String value9)
I18nHelper
getText
in interface I18nHelper
key
- the key of the i18n messagevalue1
- a value to be substituted into the messagevalue2
- a value to be substituted into the messagevalue3
- a value to be substituted into the messagevalue4
- a value to be substituted into the messagevalue5
- a value to be substituted into the messagevalue6
- a value to be substituted into the messagevalue7
- a value to be substituted into the messagevalue8
- a value to be substituted into the messagevalue9
- a value to be substituted into the message
public String getText(String key, Object parameters)
I18nHelper
List
} or a single parameter object. It will be then
used as substitution parameters within the message.
getText
in interface I18nHelper
key
- the key of the i18n messageparameters
- This can be an Array, a List
and Array or a single object parameter
public ResourceBundle getResourceBundle()
getResourceBundle
in interface I18nHelper
I18nHelper.getDefaultResourceBundle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |