Toolkits Swing JavaFX SWT Pivot Qt Lanterna Console
Platforms
  • linux
  • macosx
  • windows
  • solaris
Framework
License Apache Software License 2.0
Documentation No documentation link provided
 Tags

Downloads 808
Rating
(0)

Authored by:

Andres Almiray
aalmiray@yahoo.com
Alexander Klein
info@aklein.org

Provides internationalization support using Spring's MessageSource.

This plugin delivers a provider for the i18n-support plugin.

Usage

The i18n provider delivered by this plugin suports the following methods

String getMessage(String key) throws NoSuchMessageException
String getMessage(String key, Locale locale) throws NoSuchMessageException
String getMessage(String key, Object[] args) throws NoSuchMessageException
String getMessage(String key, Object[] args, Locale locale) throws NoSuchMessageException
String getMessage(String key, List<?> args) throws NoSuchMessageException
String getMessage(String key, List<?> args, Locale locale) throws NoSuchMessageException
String getMessage(String key, String defaultMessage)
String getMessage(String key, String defaultMessage, Locale locale)
String getMessage(String key, Object[] args, String defaultMessage)
String getMessage(String key, Object[] args, String defaultMessage, Locale locale)
String getMessage(String key, List<?> args, String defaultMessage)
String getMessage(String key, List<?> args, String defaultMessage, Locale locale)

It however does not support additional methods exposed by griffon.plugins.i18nExtendedMessageSource, which means that the args parameter sent to the various forms of the getMessage() method cannot be a Map. Additionally, GString-like replacements, like the ones found in the base i18n-support provider, are not supported.

For more information see the documentation of i18n-support plugin.

API Calls

From any object that has access to the application instance

app.getMessage('some.message.code')
app.messageSource.getMessage('some.message.code')
app.i18n.getMessage('some.message.code')

From Java code

import griffon.plugins.i18n.MessageSourceHolder
MessageSourceHolder.getInstance().getMessageSource().getMessage("some.message.code");

Configuration

Enabling the i18n provider delivered by this plugin requires the application to have the following settings in Config.groovy

i18n.provider = 'i18n'
i18n.basenames = ['messages']

The key for this provider is i18n.

You may configure additional properties files, for example assuming you have the following files

griffon-app/conf/i18n/messages.properties
griffon-app/conf/i18n/base.properties
griffon-app/conf/i18n/extended.properties

You'll configure them in Config.groovy with this setting

i18n.basenames = ['messages', 'base', 'extended']

The definition order is important as messages will be searched from first to last when mutiple files have been declared. The first file to return a non-null value for the requested message code will be the winner.