Every HiveMind module may have its own set of messages. Messages are stored alongside the module deployment descriptor, as META-INF/hivemodule.properties (within the module's JAR).
Services can gain access to localized messages, as an instance of Messages , which includes methods for accessing messages and formatting messages with arguments.
In a module descriptor, within the <contribution> and <invoke-factory> elements, you can reference a localized message in an attribute or element content simply by prefixing the message key with '%'. Examples:
<contribution configuration-id=...> <some-item <message="%message.key"> %other.message.key </some-item> </contribution>
The two keys (message.key and other.message.key ) are searched for in the contributing module's messages.
HiveMind gracefully recovers from undefined messages. If a message is not in the properties file, then HiveMind provides a substitute value by converting the key to upper-case and adding brackets, i.e. [MESSAGE.KEY]. This allows your application to continue running, but clearly identifies missing messages.
By adding additional files, message localization can be accomplished. For example, adding a second file, META-INF/hivemodule_fr.properties would provide French language localizations. Any common keys between the two files defer to the more specific file.
Setting the locale
Threads will always use this locale by default, but the locale for an individual thread may be changed using the hivemind.ThreadLocale service. The Messages injected into your services automatically adjusts for the thread's current locale.
You should not store, in your services, any localized values, since different threads may want different localizations. Instead, you should always obtain values from the Messages.