Package eu.bandm.tools.message
Class MessageTranslator<D>
- Type Parameters:
D
- the type of the document identifier
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>
Translates the text of the message and all embedded sub-structures.
The text object and all
PreMessage
type objects contained
in the arguments are translated.
Arguments of type String are not translated. For translation,
they must be wrapped by
PreMessage.preMessage(String,Object...)
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CatalogByString
CatalogByString
for the translations.static final Catalog
<Message.Kind> The printed names of the message kinds in different languages.Preference list of languages into which to translage.Fields inherited from class eu.bandm.tools.message.SingleSender
receiver
-
Constructor Summary
ConstructorsConstructorDescriptionOnly constructorMessageTranslator
(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.void
receive
(SimpleMessage<D> m) Translates the text of the message and passes it to the current drain.void
Set the catalog to be used for translations.void
setPreferences
(String... list) Set the priority of languages for searching a translation.void
setPreferences
(List<String> list) Set the priority of languages for searching a translation.Methods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Field Details
-
preferences
Preference list of languages into which to translage.- See Also:
-
catalog
CatalogByString
for the translations. -
kindPrintName
The printed names of the message kinds in different languages. ("warning", "error", etc. vs. "Warnung", "Programmfehler", etc.)
-
-
Constructor Details
-
MessageTranslator
public MessageTranslator()Only constructor -
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
Set the priority of languages for searching a translation.- Parameters:
list
- of the languages in the order of decreasing priority
-
setPreferences
Set the priority of languages for searching a translation.- Parameters:
list
- of the languages in the order of decreasing priority
-
setCatalog
Set the catalog to be used for translations.- Parameters:
cat
- the catalog to use
-
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>>
- Parameters:
m
- the message to receive.
-
process
Returns a new message with all texts translated. This includes the translation of embeddedPreMessages
.- Parameters:
msg
- the message to translate- Returns:
- the translated message
-