Class LocalisationTools
- java.lang.Object
-
- de.aristaflow.adept2.model.common.i18n.LocalisationTools
-
public final class LocalisationTools extends Object
Tool methods for localising log and check report messages. UnlikeLocaleTools
this also supportsLocalisedString
s, that are localised string representations of variables from the calling context. For instance model elements like node or instance names will be localised in the message.
-
-
Constructor Summary
Constructors Constructor Description LocalisationTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<Locale,String>
fillLocalisedMessage(Map<Locale,String> localisedMessage, String msgKey, List<Locale> locales, Function<Locale,Messages> provider, LocalisationFactory locFac, LocalisedString... args)
Loads the designated message key from the corresonding messages for the designated locales and stores them in the designated map.static String
getLocalisedMessage(String msgKey, Locale locale, Function<Locale,Messages> provider, LocalisationFactory locFac, LocalisedString... args)
Gets the localised message for the designated message key for the messages from the designated provider.
-
-
-
Method Detail
-
getLocalisedMessage
public static String getLocalisedMessage(String msgKey, Locale locale, Function<Locale,Messages> provider, LocalisationFactory locFac, LocalisedString... args)
Gets the localised message for the designated message key for the messages from the designated provider. The designated localised strings will be resolved and merged with the message for the designated message key from the messages. The resulting localised message is then returned. This may be a fallback locale for the requested locale.- Parameters:
msgKey
- The message key with which to retrieve the localisation from the resource bundle.locale
- The locale for which to retrieve the localisation for the designated message key.provider
- The provider for the localised messages.locFac
- The localisation factory for localising the strings. If this isnull
, no special localisation will be applied to the strings.args
- Optional arguments localised and afterwards passed to the corresponding localised message usingString.format(Locale, String, Object...)
.- Returns:
- The requested localised message.
- See Also:
Messages.getString(String, Object...)
-
fillLocalisedMessage
public static Map<Locale,String> fillLocalisedMessage(Map<Locale,String> localisedMessage, String msgKey, List<Locale> locales, Function<Locale,Messages> provider, LocalisationFactory locFac, LocalisedString... args)
Loads the designated message key from the corresonding messages for the designated locales and stores them in the designated map. That is, the appropriate messages will be retrieved from the designated provider for each of the designated locales. The designated localised strings will be resolved and merged with the message for the designated message key from the messages. The resulting localised message is then stored in the designated map using the actual locale of the messages. This locale may be a fallback for the requested locale. The root locale will always be included.- Parameters:
localisedMessage
- The map to store the localised message with the locale of the corresponding resource bundle as key. If this isnull
a new map will be created and returned.msgKey
- The message key with which to retrieve the localisation from the resource bundles.locales
- The locales for which to retrieve localisations for the designated message key.provider
- The provider for the localised messages.locFac
- The localisation factory for localising the strings. If this isnull
, no special localisation will be applied to the strings.args
- Optional arguments localised and afterwards passed to the corresponding localised message usingString.format(Locale, String, Object...)
.- Returns:
- The designated map containing the requested localisations. This is the designated map
unless
null
is provided. Ifnull
is provided a new map will be created. - See Also:
LocaleTools.fillLocalisedMessage(Map, String, List, Function, Object...)
-
-