Package eu.bandm.tools.muli
Class MessageTranslator<D>
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>
Translates the text (and possibly some arguments) of a
SimpleMessage.args
into
another (human) language.
Then String.format(String,Object[])
is applied to the result and the
arguments.
If a MessageFormatter.Formandum
is found in the arguments, the same process
is applied an its result used as an argument.-
Field Summary
Modifier and TypeFieldDescriptionprotected CatalogByString
CatalogByString
for the translations.static final Catalog<Message.Kind>
Preference list of languages into which to translage.Fields inherited from class eu.bandm.tools.message.SingleSender
receiver
-
Constructor Summary
ConstructorDescriptionMessageTranslator
(MessageReceiver<SimpleMessage<D>> rec, CatalogByString catalog, String... langs) Constructor which sets all parameters.MessageTranslator
(MessageReceiver<SimpleMessage<D>> rec, CatalogByString catalog, List<String> langs) Constructor which sets all parameters. -
Method Summary
Modifier and TypeMethodDescriptionprocess
(SimpleMessage<D> msg) Returns a new message with all texts translated, also of all embeddings.void
receive
(SimpleMessage<D> m) Translates the text of the message and passes it to the current drain.void
Evidentvoid
setPreferences
(String... list) Evidentvoid
setPreferences
(List<String> list) EvidentMethods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
-
Field Details
-
preferences
Preference list of languages into which to translage.- See Also:
-
catalog
CatalogByString
for the translations. -
kindPrintName
-
-
Constructor Details
-
MessageTranslator
public MessageTranslator() -
MessageTranslator
public MessageTranslator(MessageReceiver<SimpleMessage<D>> rec, CatalogByString catalog, String... langs) Constructor which sets all parameters.- Parameters:
rec
- drain to which messages will be sent,catalog
- of translationslangs
- language preferences
-
MessageTranslator
public MessageTranslator(MessageReceiver<SimpleMessage<D>> rec, CatalogByString catalog, List<String> langs) Constructor which sets all parameters.- Parameters:
rec
- drain to which messages will be sent,catalog
- of translationslangs
- language preferences
-
-
Method Details
-
setPreferences
Evident -
setPreferences
Evident -
setCatalog
Evident -
receive
Translates the text of the message and passes it to the current drain. For the translation @see process(SimpleMessage)- Specified by:
receive
in interfaceMessageReceiver<D>
- Overrides:
receive
in classMessagePasser<SimpleMessage<D>>
-
process
Returns a new message with all texts translated, also of all embeddings.
-