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 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(Locale locale)
           
I18nBean(Locale locale, ClassLoader classLoader)
           
I18nBean(String localeStr)
           
I18nBean(User user)
           
I18nBean(User user, ClassLoader classLoader)
           
I18nBean(User user, String additionalResourceBundle)
          Deprecated. with Plugins-2 this shouldn't be necessary. We now load all I18n resources in all plugins automatically.
I18nBean(User user, String additionalResourceBundle, 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(String additionalResourceBundle)
           
 Collection<ResourceBundle> getBundles()
           
 ResourceBundle getDefaultResourceBundle()
           
 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(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()
           
 String getText(String key)
           
 String getText(String key, Object parameters)
          A parameterised i18n'zed message
 String getText(String key, Object value1, Object value2, Object value3)
           
 String getText(String key, Object value1, Object value2, Object value3, Object value4)
           
 String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5)
           
 String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6)
           
 String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)
           
 String getText(String key, Object value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7, Object value8)
           
 String getText(String key, String value1)
           
 String getText(String key, String value1, String value2)
           
 String getText(String key, String value1, String value2, String value3)
           
 String getText(String key, String value1, String value2, String value3, String value4)
           
 String getText(String key, String value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, String value9)
           
 String getUnescapedText(String key)
          Get the raw property value, complete with {0}'s.
 boolean hasKey(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(Locale locale,
                ClassLoader classLoader)

I18nBean

public I18nBean()

I18nBean

public I18nBean(User user)

I18nBean

public I18nBean(String localeStr)

I18nBean

public I18nBean(User user,
                ClassLoader classLoader)

I18nBean

public I18nBean(Locale locale)

I18nBean

@Deprecated
public I18nBean(User user,
                           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(User user,
                           String additionalResourceBundle,
                           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 Locale getLocaleFromUser(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(String additionalResourceBundle)

getBundles

public Collection<ResourceBundle> getBundles()

getLocale

public Locale getLocale()
Specified by:
getLocale in interface I18nHelper

hasKey

public boolean hasKey(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 String getText(String key)
Specified by:
getText in interface I18nHelper

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

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

getText

public String getText(String key,
                      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 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)
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 ResourceBundle getDefaultResourceBundle()
Specified by:
getDefaultResourceBundle in interface I18nHelper

getPluginAccessor

protected com.atlassian.plugin.PluginAccessor getPluginAccessor()


Copyright © 2002-2010 Atlassian. All Rights Reserved.