|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lyrisoft.util.i18n.Translator
This class "translates" things by using a specially formatted varibles that can be substituted. A properties file, which is really just key/value pairs, might look something like this:
user.not.found=The user, {0}, was not found. invited={0} has invited you to {1}{0} through {n} can be used inside of any message string to allow variable substition.
Given the properties file above, this call:
getMessage("invited", "jack", "jack's room");Would return
Jack has invited you to jack's roomThe "translation" part is actually a manual step, in that somebody has to actually create a translated version of the properties file(s).
Constructor Summary | |
Translator()
|
|
Translator(java.util.Properties p)
Construct a Translator that will used the specified Properties. |
Method Summary | |
java.lang.String |
getMessage(java.lang.String key)
Get a message without any variable substition. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.String arg1)
Get a message and substitute {0} with arg1 |
java.lang.String |
getMessage(java.lang.String key,
java.lang.String[] args)
The most general case of substituting variables: {0} thru {n} are substibuted with args[0] thru args[n]. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.String arg1,
java.lang.String arg2)
Get a message and substitute {0} and {1} with arg1 and arg2 |
java.lang.String |
getMessage(java.lang.String key,
java.lang.String arg1,
java.lang.String arg2,
java.lang.String arg3)
Get a message and substitute {0}, {1}, and {2} with arg1, arg2, and arg3. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Translator(java.util.Properties p)
public Translator()
Method Detail |
public java.lang.String getMessage(java.lang.String key)
public java.lang.String getMessage(java.lang.String key, java.lang.String arg1)
public java.lang.String getMessage(java.lang.String key, java.lang.String arg1, java.lang.String arg2)
public java.lang.String getMessage(java.lang.String key, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3)
public java.lang.String getMessage(java.lang.String key, java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |