Recommanded practise for internationalization are:
-
store messages using
ResourceBundle
properties file in your component module -
the location of the properties are in the same package than the related component(s) and is named
Messages
(ex:org.talend.demo.MyComponent
will useorg.talend.demo.Messages[locale].properties
) -
for your own messages use the internationalization API
Overal idea is to design its messages as methods returning String
values
and back the template by a ResourceBundle
located in the same package than the interface
defining these methods and named Messages
.
Important
|
this is the mecanism to use to internationalize your own messages in your own components. |
To ensure you internationalization API is identified you need to mark it with @Internationalized
:
@Internationalized (1)
public interface Translator {
String message();
String templatizedMessage(String arg0, int arg1); (2)
String localized(String arg0, @Language Locale locale); (3)
}
-
@Internationalized
allows to mark a class as a i18n service -
you can pass parameters and the message will use
MessageFormat
syntax to be resolved based on theResourceBundle
template -
you can use
@Language
on aLocale
parameter to specify manually the locale to use, note that a single value will be used (the first parameter tagged as such).