com.atlassian.jira.web.bean
Class I18nBean

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

public class I18nBean
extends java.lang.Object
implements I18nHelper

Bean that searches for i18n text in JiraWebActionSupport.properties Can be used by Classes that do not inherit from JiraWebActionSupport (and hence don't have access to the getText()) Please note that getText() in this bean ONLY searches the JiraWebActionSupport.properties file.


Nested Class Summary
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(java.util.Locale locale)
           
I18nBean(java.util.Locale locale, java.lang.ClassLoader classLoader)
           
I18nBean(java.lang.String localeStr)
           
I18nBean(com.opensymphony.user.User user)
           
I18nBean(com.opensymphony.user.User user, java.lang.ClassLoader classLoader)
           
I18nBean(com.opensymphony.user.User user, java.lang.String additionalResourceBundle)
          Deprecated. with Plugins-2 this shouldn't be necessary. We now load all I18n resources in all plugins automatically.
I18nBean(com.opensymphony.user.User user, java.lang.String additionalResourceBundle, java.lang.ClassLoader classLoader)
          Deprecated. with Plugins-2 this shouldn't be necessary. We now load all I18n resources in all plugins automatically.
 
Method Summary
 void addResourceBundle(java.lang.String additionalResourceBundle)
           
 java.util.Collection<java.util.ResourceBundle> getBundles()
           
 java.util.ResourceBundle getDefaultResourceBundle()
           
 java.util.Set<java.lang.String> getKeysForPrefix(java.lang.String prefix)
          Given a prefix for an i18n key, this method will return all keys that start with the prefix specified.
 java.util.Locale getLocale()
           
static java.util.Locale getLocaleFromUser(com.opensymphony.user.User user)
          This method is temporary and will be replaced when we move to a crowd-based User API.
protected  com.atlassian.plugin.PluginAccessor getPluginAccessor()
           
 java.lang.String getText(java.lang.String key)
           
 java.lang.String getText(java.lang.String key, java.lang.Object parameters)
          A parameterised i18n'zed message
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3)
           
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4)
           
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5)
           
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6)
           
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7)
           
 java.lang.String getText(java.lang.String key, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7, java.lang.Object value8)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1, java.lang.String value2)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1, java.lang.String value2, java.lang.String value3)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5, java.lang.String value6, java.lang.String value7)
           
 java.lang.String getText(java.lang.String key, java.lang.String value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5, java.lang.String value6, java.lang.String value7, java.lang.String value8, java.lang.String value9)
           
 java.lang.String getUnescapedText(java.lang.String key)
          Get the raw property value, complete with {0}'s.
 boolean hasKey(java.lang.String key)
          Returns true if a translation for the specified key is present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I18nBean

public I18nBean(java.util.Locale locale,
                java.lang.ClassLoader classLoader)

I18nBean

public I18nBean()

I18nBean

public I18nBean(com.opensymphony.user.User user)

I18nBean

public I18nBean(java.lang.String localeStr)

I18nBean

public I18nBean(com.opensymphony.user.User user,
                java.lang.ClassLoader classLoader)

I18nBean

public I18nBean(java.util.Locale locale)

I18nBean

@Deprecated
public I18nBean(com.opensymphony.user.User user,
                           java.lang.String additionalResourceBundle)
Deprecated. with Plugins-2 this shouldn't be necessary. We now load all I18n resources in all plugins automatically.

Parameters:
user - user whose Locale should be used
additionalResourceBundle - path to additional resource bundle to add to I18nBean

I18nBean

@Deprecated
public I18nBean(com.opensymphony.user.User user,
                           java.lang.String additionalResourceBundle,
                           java.lang.ClassLoader classLoader)
Deprecated. with Plugins-2 this shouldn't be necessary. We now load all I18n resources in all plugins automatically.

Parameters:
user - user whose Locale should be used
additionalResourceBundle - path to additional resource bundle to add to I18nBean
classLoader - class loader to use to load bundles
Method Detail

getLocaleFromUser

public static java.util.Locale getLocaleFromUser(com.opensymphony.user.User user)
This method is temporary and will be replaced when we move to a crowd-based User API. This method is almost guaranteed to change.

Parameters:
user - the user
Returns:
the user's specified Locale
Since:
4.1

addResourceBundle

public void addResourceBundle(java.lang.String additionalResourceBundle)

getBundles

public java.util.Collection<java.util.ResourceBundle> getBundles()

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface I18nHelper

hasKey

public boolean hasKey(java.lang.String key)
Returns true if a translation for the specified key is present. Useful for where a single key has replaced another (or perhaps a series), eg: #if ($i18n.hasKey("new.key") $i18n.getText("new.key", a, b) #else $i18n.getText("old.key") #end

Parameters:
key - message resource key
Returns:
true if a translation for the specified key is present, false otherwise

getText

public java.lang.String getText(java.lang.String key)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1,
                                java.lang.String value2,
                                java.lang.String value3,
                                java.lang.String value4)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1,
                                java.lang.String value2)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1,
                                java.lang.String value2,
                                java.lang.String value3)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object value1,
                                java.lang.Object value2,
                                java.lang.Object value3)

getText

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

getText

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

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object value1,
                                java.lang.Object value2,
                                java.lang.Object value3,
                                java.lang.Object value4,
                                java.lang.Object value5,
                                java.lang.Object value6)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1,
                                java.lang.String value2,
                                java.lang.String value3,
                                java.lang.String value4,
                                java.lang.String value5,
                                java.lang.String value6,
                                java.lang.String value7)
Specified by:
getText in interface I18nHelper

getText

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

getText

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

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String value1,
                                java.lang.String value2,
                                java.lang.String value3,
                                java.lang.String value4,
                                java.lang.String value5,
                                java.lang.String value6,
                                java.lang.String value7,
                                java.lang.String value8,
                                java.lang.String value9)
Specified by:
getText in interface I18nHelper

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object parameters)
A parameterised i18n'zed message

Specified by:
getText in interface I18nHelper
Parameters:
parameters - A single object, or array of objects, or list of objects

getKeysForPrefix

public java.util.Set<java.lang.String> getKeysForPrefix(java.lang.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 java.lang.String getUnescapedText(java.lang.String key)
Get the raw property value, complete with {0}'s.

Specified by:
getUnescapedText in interface I18nHelper
Parameters:
key - Non-null key to look up
Returns:
Unescaped property value for the key, or the key itself if no property with the specified key is found

getDefaultResourceBundle

public java.util.ResourceBundle getDefaultResourceBundle()
Specified by:
getDefaultResourceBundle in interface I18nHelper

getPluginAccessor

protected com.atlassian.plugin.PluginAccessor getPluginAccessor()


Copyright © 2002-2010 Atlassian. All Rights Reserved.