br.usp.ime.xpusp.util
Class Xpuspi18n
java.lang.Object
|
+--br.usp.ime.xpusp.util.Xpuspi18n
- All Implemented Interfaces:
- org.apache.turbine.services.pull.ApplicationTool
- public class Xpuspi18n
- extends java.lang.Object
- implements org.apache.turbine.services.pull.ApplicationTool
This is a class used as a localization tool. It is present
on all templates and can be referenced by $i18n.
$i18n.key returns the key translated to the current locale.
It is initialized with the Default XpuspBundle.properties file.
It can be used in junction with the XpuspInfo utility for messages that need pattern substitution
$i18n.format("key",xpuspinfo.addArray($value1).addArray($value2).toArray()) will substitute keys {0} and {1} in "key" (specified in the correct bundle) to $value1 and $value2 respectively.
 | Source Forge Info |
|---|
| CVS File : | Xpuspi18n.java |
|---|
| User : | krico |
|---|
| Version : | 1.4 |
|---|
| Date : | 2002/05/09 18:05:58 |
|---|
|
Field Summary |
private java.util.ResourceBundle |
rb
|
(package private) org.apache.turbine.om.security.User |
user
|
|
Constructor Summary |
Xpuspi18n()
Constructs a new xpuspi18n using the default bundle "XpuspBundle". |
Xpuspi18n(java.lang.String bundleName)
Construct a new Xpuspi18n using bundleName as a bundle |
|
Method Summary |
java.lang.String |
format(java.lang.String key,
java.lang.Object[] param)
Gets the translation for key using the current bundle/locale. |
java.lang.String |
get(java.lang.String key)
Gets the translation for key using the current bundle/locale. |
java.util.ResourceBundle |
getBundle()
Returns the ResourceBundle in use. |
static Xpuspi18n |
getDefaultBundle()
|
static Xpuspi18n |
getInternalBundle()
|
java.lang.String |
getString(java.lang.String key)
|
void |
init(java.lang.Object data)
This is called by the system to initialize this tool as a session tool |
void |
refresh()
called by the system to refresh it |
void |
setBundle(java.util.ResourceBundle rb)
Sets the ResourceBundle. |
void |
setLocale(java.util.Locale l)
Sets the Locale to be used. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
rb
private java.util.ResourceBundle rb
user
org.apache.turbine.om.security.User user
Xpuspi18n
public Xpuspi18n()
- Constructs a new xpuspi18n using the default bundle "XpuspBundle".
This is basically the same as calling new Xpuspi18n("XpuspBundle");
Xpuspi18n
public Xpuspi18n(java.lang.String bundleName)
- Construct a new Xpuspi18n using
bundleName as a bundle
init
public void init(java.lang.Object data)
- This is called by the system to initialize this tool as a session tool
- Specified by:
init in interface org.apache.turbine.services.pull.ApplicationTool
refresh
public void refresh()
- called by the system to refresh it
- Specified by:
refresh in interface org.apache.turbine.services.pull.ApplicationTool
getInternalBundle
public static Xpuspi18n getInternalBundle()
getDefaultBundle
public static Xpuspi18n getDefaultBundle()
setBundle
public void setBundle(java.util.ResourceBundle rb)
- Sets the ResourceBundle.
- Parameters:
rb - ResourceBundle to be used.
getBundle
public java.util.ResourceBundle getBundle()
- Returns the ResourceBundle in use.
- Returns:
- ResourceBundle in use.
getString
public java.lang.String getString(java.lang.String key)
get
public java.lang.String get(java.lang.String key)
- Gets the translation for
key using the current bundle/locale.
- Parameters:
key - The key we are searching for.- Returns:
- The translation found for the key in the current bundle.
setLocale
public void setLocale(java.util.Locale l)
- Sets the Locale to be used.
- Parameters:
l - Locale to be used.
format
public java.lang.String format(java.lang.String key,
java.lang.Object[] param)
- Gets the translation for
key using the current bundle/locale.
In this case key is a pattern like specified in MessageFormat
and param is the array of objects we will use for pattern substitution.
- Parameters:
key - The key we are searching for.param - The Object array containing the objects we will insert into the message.- Returns:
- The translation found for the key in the current bundle.