On Jan 16, 2013, at 10:37 AM, Thomas Mortagne <thomas.mortagne(a)xwiki.com> wrote:
Hi devs,
A missing peace of Extension Manager UI is the fact that the log
associated to a task is not translatable right now. So I'm working on
making easy to translation log in general since that's actually what
EM is displaying: just plain standard slf4j log (see
http://jira.xwiki.org/browse/XCOMMONS-304).
= Possibilities =
Here are several possibilities:
1) translate the message before giving it to the log event, so it's up
to the log producer to translation its log based on the context
language
2) provide an additional translation key along with what will now be
the default message when logging
3) generate a translation key based on the default message
Here is what I think of those:
1) is a bit better for the user than the current situation but not
that much, instead of behind stuck with english he will be stuck with
another language with stored logs. It also make anyone that produce
log depends on many things to actually translate that message so it's
a -1 for me
3) sounds very fragile
= The actual proposal =
Here is a detailed proposal for 2):
The idea would be to pass the translation key using slf4j Marker API.
We introduce a TranslationMarker which implements Marker and is passed
with the log when you want to associated a translation key to a log.
Here is an example:
producer (for example the install job):
""
logger.error(TranslationMarker.getMarker("some.translation.key"), "A
default error message generally in english with a [{}]", "parameter",
exception)
""
displayer (for example the Extension Manager UI, should be a logging
module UI element btw reused by Extension Manager ;)):
""
#set($translationKey = $logEvent.marker.translationKey)
""
WDYT ?
So it would be up to the user of the log to generate the translation based on the key it
retrieves?
Is it not interesting to have LogEvent.getMessage to return the translated message (it
would check if a TranslationMarker exists and if so it would get the translation)?
Alternatively we could provide a getTranslatedMessage() API too.
+1 for 2) in general.
Thanks
-Vincent