Package com.oorian.i18n
Class ResourceBundleMessageResolver
java.lang.Object
com.oorian.i18n.ResourceBundleMessageResolver
- All Implemented Interfaces:
MessageResolver
Resolves messages from Java
ResourceBundle property files, with locale awareness.
Loads message templates from .properties files using the standard Java resource
bundle mechanism. The locale is determined by OorianLocale.get(), so messages are
automatically resolved in the user's current locale.
If a key is not found in the locale-specific bundle, the resolver falls back to the
DefaultMessages English defaults.
Property file naming:
ValidationMessages.properties— default (English)ValidationMessages_de.properties— GermanValidationMessages_fr.properties— FrenchValidationMessages_ja.properties— Japanese
Example property file (ValidationMessages_de.properties):
validation.required = Dieses Feld ist erforderlich
validation.email = Bitte geben Sie eine gültige E-Mail-Adresse ein
validation.length.between = Muss zwischen {min} und {max} Zeichen lang sein
Usage:
// Configure in Application.initialize()
MessageConfiguration.setMessageResolver(
new ResourceBundleMessageResolver("ValidationMessages"));
// Messages are now resolved per-locale
OorianLocale.set(Locale.GERMANY);
MessageConfiguration.resolve(DefaultMessages.REQUIRED);
// → "Dieses Feld ist erforderlich"
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionResourceBundleMessageResolver(String baseName) Creates a new resource bundle message resolver. -
Method Summary
-
Constructor Details
-
ResourceBundleMessageResolver
Creates a new resource bundle message resolver.- Parameters:
baseName- the base name of the resource bundle (e.g.,"ValidationMessages")
-
-
Method Details
-
resolve
Resolves a message from the resource bundle for the current locale.The locale is obtained from
OorianLocale.get(). If the key is not found in the bundle, resolution falls back toDefaultMessages.- Specified by:
resolvein interfaceMessageResolver- Parameters:
key- the message keyparams- alternating key-value pairs for parameter substitution- Returns:
- the resolved and parameterized message
-