Class LocalizedStringsSet
locale.
The locale dependent strings have to be stored in property files. They are accessed via Java's
ResourceBundle. To access the property files, they all have to
be in the same package and must start with the same prefix. Therefore the set's qualified name is
the package name, followed by a dot (.), followed by the prefix, e.g.
"org.faktorips.fl.Messages". For further information see the ResourceBundle documentation.
If a localized String contains sections that have to be replaced with locale dependent
replacements before the String is presented to a user, you can use one of the methods taking
replacement objects as a parameter. The mechanism used here is the one of
MessageFormat.
Example:
In the message "The sum insured must be at least {0}." the sum insured must be inserted at runtime depending on the chosen product.
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizedStringsSet(Class<?> clazz) Creates a new set that uses the indicated class' name as qualified name.LocalizedStringsSet(String qualifiedName, ClassLoader loader) Creates a new StringsSet with the indicated qualified name. -
Method Summary
Modifier and TypeMethodDescriptionTry to load the resource bundle in the jvm's default language and searches for the given key.Try to load the resource bundle in the jvm's default language and searches for the given key.Try to load the resource bundle in given locale and searches for the given key.Try to load the resource bundle in given locale and searches for the given key.booleanisAccessible(Locale locale) Checking whether the resource is accessible in given locale.
-
Constructor Details
-
LocalizedStringsSet
Creates a new set that uses the indicated class' name as qualified name.- Throws:
IllegalArgumentException- if the clazz is null.
-
LocalizedStringsSet
Creates a new StringsSet with the indicated qualified name. The property files are loaded with the indicated classloader.- Throws:
IllegalArgumentException- if the qualifiedName is null.
-
-
Method Details
-
isAccessible
Checking whether the resource is accessible in given locale. That does not necessary means that the resource is available in exactly this language when there is a default resource.- Parameters:
locale- The locale you want be check.- Returns:
- true if there is a resource bundle could be found for the given locale
- See Also:
-
getString
Try to load the resource bundle in given locale and searches for the given key. This method also replaces the replacement parameters in the found message by using theMessageFormat.- Parameters:
key- The key of the messagelocale- the locale of the messagereplacements- optional replacement parameters- Returns:
- the message for the key in specified locale
- Throws:
MissingResourceException- if the resource or the specified key is not found- See Also:
-
getString
Try to load the resource bundle in given locale and searches for the given key.- Parameters:
key- The key of the messagelocale- the locale of the message- Returns:
- the message for the key in specified locale
- Throws:
MissingResourceException- if the resource or the specified key is not found- See Also:
-
getString
Try to load the resource bundle in the jvm's default language and searches for the given key. This method also replaces the replacement parameters in the found message by using theMessageFormat.- Parameters:
key- The key of the messagereplacements- optional replacement parameters- Returns:
- the message for the key in specified locale
- Throws:
MissingResourceException- if the resource or the specified key is not found- See Also:
-
getString
Try to load the resource bundle in the jvm's default language and searches for the given key.- Parameters:
key- The key of the message- Returns:
- the message for the key in specified locale
- Throws:
MissingResourceException- if the resource or the specified key is not found- See Also:
-