com.atlassian.jira.web.bean
Class I18nBean

java.lang.Object
  extended by com.atlassian.jira.web.bean.I18nBean
All Implemented Interfaces:
I18nHelper
Direct Known Subclasses:
MockI18nBean

public class I18nBean
extends Object
implements I18nHelper

In an attempt to make use of our I18n-cache this was turned into a flyweight that delegates to the properly BackingI18n that lives in the caching factory.

Unit tests should never use this. Use the MockI18nHelper or BackingI18n (if you must).

You should not be dealing with this Concrete Class - see I18nHelper instead.

Since:
v4.3 this become a flyweight that wraps the cached version of the Real Thing.
See Also:
I18nHelper, JiraAuthenticationContext.getI18nHelper(), I18nHelper.BeanFactory

Nested Class Summary
static class I18nBean.AccessorFactory
          Small delegate around the CachingI18nHelperFactory that is registered in pico as the actual I18nHelper.BeanFactory
static class I18nBean.CachingFactory
          As the name implies: a factory that caches I18nBeans.
 
Nested classes/interfaces inherited from interface com.atlassian.jira.util.I18nHelper
I18nHelper.BeanFactory
 
Constructor Summary
I18nBean()
           
I18nBean(I18nHelper delegate)
           
I18nBean(Locale locale)
           
I18nBean(String localeString)
          Deprecated. use I18nBean(java.util.Locale) instead
I18nBean(com.atlassian.crowd.embedded.api.User user)
           
 
Method Summary
 ResourceBundle getDefaultResourceBundle()
           
protected  I18nHelper.BeanFactory getFactory()
           
 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(com.atlassian.crowd.embedded.api.User user)
           
 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)
          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 I18nHelper.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.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I18nBean

public I18nBean()

I18nBean

public I18nBean(Locale locale)

I18nBean

public I18nBean(com.atlassian.crowd.embedded.api.User user)

I18nBean

public I18nBean(I18nHelper delegate)

I18nBean

@Deprecated
public I18nBean(String localeString)
Deprecated. use I18nBean(java.util.Locale) instead

Construct an I18nBean in the given Locale.

Parameters:
localeString - The locale String. eg "fr_CA"
Method Detail

getLocaleFromUser

public static Locale getLocaleFromUser(com.atlassian.crowd.embedded.api.User user)
Parameters:
user - the user
Returns:
the user's specified Locale
Since:
4.1

getFactory

protected I18nHelper.BeanFactory getFactory()

getLocale

public Locale getLocale()
Specified by:
getLocale in interface I18nHelper
Returns:
the Locale that is associated with this I18nHelper

getDefaultResourceBundle

public ResourceBundle getDefaultResourceBundle()
Specified by:
getDefaultResourceBundle in interface I18nHelper
Returns:
the default ResourceBundle within JIRA

getKeysForPrefix

public Set<String> getKeysForPrefix(String prefix)
Description copied from interface: I18nHelper
Given a prefix for an i18n key, this method will return all keys that start with the prefix specified.

Specified by:
getKeysForPrefix in interface I18nHelper
Parameters:
prefix - The prefix for i18n keys. May not be null
Returns:
An immutable set of translation keys that start with the prefix specified.

getUnescapedText

public String getUnescapedText(String key)
Description copied from interface: I18nHelper
Called to return the un-formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getUnescapedText in interface I18nHelper
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

getUntransformedRawText

public String getUntransformedRawText(String key)
Description copied from interface: I18nHelper
Same as I18nHelper.getUnescapedText(String) but does not apply any TranslationTransforms.

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

isKeyDefined

public boolean isKeyDefined(String key)
Description copied from interface: I18nHelper

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 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.

Specified by:
isKeyDefined in interface I18nHelper
Parameters:
key - translation key
Returns:
true, if any translation for such key exists, false otherwise

getText

public String getText(String key)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

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

getText

public String getText(String key,
                      String value1)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object parameters)
Description copied from interface: I18nHelper
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.

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      String value1,
                      String value2)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      String value1,
                      String value2,
                      String value3)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3,
                      Object value4)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      String value1,
                      String value2,
                      String value3,
                      String value4)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3,
                      Object value4,
                      Object value5)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3,
                      Object value4,
                      Object value5,
                      Object value6)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3,
                      Object value4,
                      Object value5,
                      Object value6,
                      Object value7)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      String value1,
                      String value2,
                      String value3,
                      String value4,
                      String value5,
                      String value6,
                      String value7)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      Object value1,
                      Object value2,
                      Object value3,
                      Object value4,
                      Object value5,
                      Object value6,
                      Object value7,
                      Object value8)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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

getText

public String getText(String key,
                      String value1,
                      String value2,
                      String value3,
                      String value4,
                      String value5,
                      String value6,
                      String value7,
                      String value8,
                      String value9)
Description copied from interface: I18nHelper
Called to return the formatted text of the specified i18n key or the key itself if no message can be found

Specified by:
getText in interface I18nHelper
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


Copyright © 2002-2013 Atlassian. All Rights Reserved.