|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbuoy.xml.WidgetLocalization
public class WidgetLocalization
This class cooperates with WidgetEncoder
and WidgetDecoder
to localized the
text stored in XML files. Rather than containing the actual text which will appear in the
user interface, the XML file contains keys which are looked up from a ResourceBundle at
decoding time. This class maintains a list of String objects which are to be localized at
encoding time, and performs the actual substitution at decoding time.
To use this class, follow these steps:
menu.file=File
menu.edit=Edit
menu.setText("menu.file");
WidgetLocalization.addLocalizedString("menu.file");
addLocalizedString()
, you must pass
in the exact String object which is used in the user interface. It also means that it is
possible for the same String value to appear twice in the user interface, and be localized in
one place but not in the other.
This class can also operate in another mode from that described above. Suppose a graphical GUI editor application is used to create a user interface. That application defines the Strings to be localized, then uses WidgetEncoder to save it as XML. When that file is processed by WidgetDecoder to generate the user interface for an application, the localized Strings are obtained from a ResourceBundle.
Suppose, however, that you want to reload the XML file into the GUI editor application for further editing. In that case, load the XML file with WidgetDecoder, but use one of the constructors which does not take a ResourceBundle. This will cause the user interface to be loaded exactly as it originally was before encoding. The localization keys will be loaded directly, not replaced with localized versions. Furthermore, as they are loaded, they are automatically added to the list of Strings to localize so that when the file is saved again, all of the Strings will be properly localized.
Constructor Summary | |
---|---|
WidgetLocalization()
|
Method Summary | |
---|---|
static void |
addLocalizedString(java.lang.String s)
Add a String object to the list of Strings which should be localized when the user interface is reconstructed from XML. |
static java.lang.String[] |
getAllLocalizedStrings()
Get the full list of String objects which should be localized when the user interface is reconstructed from XML. |
static java.lang.Object |
getLocalizedString(java.lang.String key)
This method is invoked during decoding to get the localized String corresponding to a key. |
static boolean |
isLocalizedString(java.lang.String s)
Determine whether a String object is currently in the list of Strings which should be localized when the user interface is reconstructed from XML. |
static void |
removeLocalizedString(java.lang.String s)
Remove a String object from the list of Strings which should be localized when the user interface is reconstructed from XML. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WidgetLocalization()
Method Detail |
---|
public static void addLocalizedString(java.lang.String s)
public static void removeLocalizedString(java.lang.String s)
public static boolean isLocalizedString(java.lang.String s)
public static java.lang.String[] getAllLocalizedStrings()
public static java.lang.Object getLocalizedString(java.lang.String key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |