|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.nand.util.i18n.mgr.StringManager
public class StringManager
String Manager for retrieving I18N localized text from .properties
bundle files.
Written for the JSettlers2 client by Luis A. Ramirez, extended and enhanced by Jeremy Monin.
Your app may want to extend this class if it has objects which want special formatting methods, or to provide and cache a single manager instance whose locale is set at startup.
Remember that bundle files are encoded not in UTF-8
but in ISO-8859-1
:
net.nand.util.i18n.gui.PTEMain
editor to compare and translate properties files
conveniently side-by-side, without needing to deal with ISO-8859-1 unicode escapes.
Field Summary | |
---|---|
protected java.util.ResourceBundle |
bundle
|
Constructor Summary | |
---|---|
StringManager(java.lang.String bundlePath)
Create a string manager for the bundles at bundlePath with the default locale. |
|
StringManager(java.lang.String bundlePath,
java.util.Locale loc)
Create a string manager for the bundles at bundlePath with a certain Locale. |
Method Summary | |
---|---|
java.lang.String |
get(java.lang.String key)
Get a localized string (having no parameters) with the given key. |
java.lang.String |
get(java.lang.String key,
java.lang.Object... arguments)
Get and format a localized string (with parameters) with the given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.ResourceBundle bundle
Constructor Detail |
---|
public StringManager(java.lang.String bundlePath)
bundlePath
with the default locale.
Remember that bundle files are encoded not in UTF-8
but in ISO-8859-1
, see class javadoc.
bundlePath
- Bundle path, will be retrieved with ResourceBundle.getBundle(String)
public StringManager(java.lang.String bundlePath, java.util.Locale loc)
bundlePath
with a certain Locale.
Remember that bundle files are encoded not in UTF-8
but in ISO-8859-1
, see class javadoc.
bundlePath
- Bundle path, will be retrieved with ResourceBundle.getBundle(String, Locale)
loc
- Locale to use; not null
Method Detail |
---|
public final java.lang.String get(java.lang.String key) throws java.util.MissingResourceException
key
- Key to use for string retrieval
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeExceptionpublic final java.lang.String get(java.lang.String key, java.lang.Object... arguments) throws java.util.MissingResourceException
key
- Key to use for string retrievalarguments
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |