|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.universAAL.ui.internationalization.util.MessageLocaleHelper
public class MessageLocaleHelper
Helper class to get the appropriate messages in the preferred (or secondary,
if preferred not available) language. Determines the Locale
of the
preferred (or secondary) Language for the user stored in
UIPreferencesSubProfile
. Then it can be used as normal messages
class, to retrieve the correct internationalized messages for the given user.
Constructor Summary | |
---|---|
MessageLocaleHelper(ModuleContext mc,
UIPreferencesSubProfile uiPreferencesSubprofile,
List<URL> urlList)
This constructor is to be used when the UIPreferencesSubProfile
is already available, IE: by the DialogManager. |
|
MessageLocaleHelper(ModuleContext mc,
User user,
List<URL> urlList)
This constructor should be used by Applications. |
Method Summary | |
---|---|
Locale |
getSelectedMessageLocale()
Get the selected Locale for the messages. |
String |
getString(String key)
Get a string in internationalization Messages file. |
String |
getString(String key,
String[] substitutions)
Like getString(String) , This method will
get the internationalization string for a given key. |
Locale |
getUserLocaleFromPreferredLanguage()
Get the language for the user. |
void |
reloadMessages()
Reloads the messages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageLocaleHelper(ModuleContext mc, User user, List<URL> urlList) throws Exception
ArrayList list = new ArrayList();
list.add(getClass().getClassLoader().getResource("messages.properties"));
list.add(new File(CONFIG_FOLDER, "messages.properties").toURI().toURL());
list.add(new URL("Form_Resource_Server"));
//list.add(Other sources, for example a web server hosting these files);
MessageLocaleHelper messages = new MessageLocaleHelper(mc, user, list);
...
messages.getString("welcomeScreen.sayHello");
mc
- The ModuleContext
to enable logging and service call.user
- The User
to address the messages.urlList
- the list of alternative URL
locations for messages.
Exception
MessageLocaleHelper#reloadMessages()}
public MessageLocaleHelper(ModuleContext mc, UIPreferencesSubProfile uiPreferencesSubprofile, List<URL> urlList) throws Exception
UIPreferencesSubProfile
is already available, IE: by the DialogManager.
mc
- uiPreferencesSubprofile
- urlList
-
Exception
MessageLocaleHelper#reloadMessages()}
Method Detail |
---|
public void reloadMessages() throws Exception
Exception
public final Locale getUserLocaleFromPreferredLanguage()
Locale
from the preferred (or if preferred not found
secondary) language for the user stored in
UIPreferencesSubProfile
.public final Locale getSelectedMessageLocale()
public final String getString(String key)
key
- the key for the string
public String getString(String key, String[] substitutions)
getString(String)
, This method will
get the internationalization string for a given key.
Aditionally it will subsitude the variables defined like "{n}" with the
String in the index n of the substitutions parameter.
key=page \{0\} of \{1\}
MessageLocaleHelper
mlh = ...
mlh.getString("key",new String[]{"1","10"});
will return: "page 1 of 10"
- Parameters:
key
- substitutions
-
- Returns:
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |