[xwiki-users] Localization module: can we have a translation string refer to another translation string ?
Hi, For some quality reasons I assigned to myself, I use the following translations for my app: MailArchiveCode.LoadingSessionClass_maxMailsNb=Max number of mails to load in a session mailarchive.loadingSession.fields.maxMailsNb.label=$services.localization.render('MailArchiveCode.LoadingSessionClass_maxMailsNb') The first one has the name expected for XClass fields mapping, the second has the name I expect for a form field translation key. But as their content must be the same in my case, I refer the one from the second. But when trying to display that in a page, I use: $services.localization.render('mailarchive.loadingSession.fields.maxMailsNb.label') ... and it shows: $services.localization.render('MailArchiveCode.LoadingSessionClass_maxMailsNb') Is there a way around ? I tried to add "{{velocity}}" around the second translation value, but of course it complains about nested scripts... Thanks, Jeremie
Officially a translation for the current default syntax is support to be plain text with just MessageFormat syntax support for (again plain text) parameters. That's the behavior you will alway get with the {{translation}} macro for example. All the translations you see with html (or worst wiki syntax) are very bad hacks. The only hack (there is no clean one) I can see (which does not work in all cases) is to use the {{translation}} macro in your second translation. MailArchiveCode.LoadingSessionClass_maxMailsNb=Max number of mails to load mailarchive.loadingSession.fields.maxMailsNb.label={{translation key="MailArchiveCode.LoadingSessionClass_maxMailsNb"}}. We really need support for variables in localization modules (something like mailarchive.loadingSession. fields.maxMailsNb.label={{MailArchiveCode.LoadingSessionClass_maxMailsNb}}) ) and I designed it in order to make easy to support it later but the localization module went lower in my priority list these days. In the meantime something you could do on your side is override the component https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... which is the current default and only syntax and put there your own placeholder system.
participants (2)
-
Jeremie BOUSQUET -
Thomas Mortagne