Hi devs, We need to support some way internationalization of everything in the rendering that appear in the UI, for now it's mainly related to macros. What I propose is to introduce the rule that any displayable String returned by the API (MacroDescriptor#getName, ParameterDescriptor#getDescription, etc.) could be a l10n key. Then the API user call the l10n component to get the final String. pros: - no need to touch the current API - it avoid having complex API to support l10n specifics and makes pretty much everything depends on l10n component. It's easier for macro author to write a quick macro with some description without having to create l10n resource and call the l10n component just for english for example. - the displayer can control how to get actual translations the way it wants - we need something like that for wiki macros anyway: XWiki does not support translations of objects yet (and for long I guess since the issue is at database level) and it would be a pain to have to copy the content of the macro by language since most of the time the script of the macro would not be related to the language cons: - it's more work for the API user to filter the String with the l10n component to get the actual final String One detail I'm not sure of is if we introduce some syntax to explicitly indicate it's a l10n key or if we just always give the String to the l10n component which will return it as it is if it can't find any matching key. Having an explicit way to indicate a String is a key would be better to track l10n keys bugs but introduce a syntax is always more complex (what chars to choose, how to escape, etc...). WDYT ? Thanks, -- Thomas Mortagne
On Oct 26, 2009, at 5:59 PM, Thomas Mortagne wrote:
Hi devs,
We need to support some way internationalization of everything in the rendering that appear in the UI, for now it's mainly related to macros.
What I propose is to introduce the rule that any displayable String returned by the API (MacroDescriptor#getName, ParameterDescriptor#getDescription, etc.) could be a l10n key. Then the API user call the l10n component to get the final String.
pros: - no need to touch the current API - it avoid having complex API to support l10n specifics and makes pretty much everything depends on l10n component. It's easier for macro author to write a quick macro with some description without having to create l10n resource and call the l10n component just for english for example. - the displayer can control how to get actual translations the way it wants - we need something like that for wiki macros anyway: XWiki does not support translations of objects yet (and for long I guess since the issue is at database level) and it would be a pain to have to copy the content of the macro by language since most of the time the script of the macro would not be related to the language
cons: - it's more work for the API user to filter the String with the l10n component to get the actual final String
One detail I'm not sure of is if we introduce some syntax to explicitly indicate it's a l10n key or if we just always give the String to the l10n component which will return it as it is if it can't find any matching key.
Having an explicit way to indicate a String is a key would be better to track l10n keys bugs but introduce a syntax is always more complex (what chars to choose, how to escape, etc...).
WDYT ?
+1 in general. Not sure either for the special delimiter. If we decide for one I'd see "@id" as a good one. Thanks -Vincent
On Mon, Oct 26, 2009 at 18:59, Thomas Mortagne <thomas.mortagne@xwiki.com> wrote:
Hi devs,
We need to support some way internationalization of everything in the rendering that appear in the UI, for now it's mainly related to macros.
What I propose is to introduce the rule that any displayable String returned by the API (MacroDescriptor#getName, ParameterDescriptor#getDescription, etc.) could be a l10n key. Then the API user call the l10n component to get the final String.
pros: - no need to touch the current API - it avoid having complex API to support l10n specifics and makes pretty much everything depends on l10n component. It's easier for macro author to write a quick macro with some description without having to create l10n resource and call the l10n component just for english for example. - the displayer can control how to get actual translations the way it wants - we need something like that for wiki macros anyway: XWiki does not support translations of objects yet (and for long I guess since the issue is at database level) and it would be a pain to have to copy the content of the macro by language since most of the time the script of the macro would not be related to the language
cons: - it's more work for the API user to filter the String with the l10n component to get the actual final String
One detail I'm not sure of is if we introduce some syntax to explicitly indicate it's a l10n key or if we just always give the String to the l10n component which will return it as it is if it can't find any matching key.
Having an explicit way to indicate a String is a key would be better to track l10n keys bugs but introduce a syntax is always more complex (what chars to choose, how to escape, etc...).
A good candidate found by Vincent would be to reuse commons-configuration syntax to insert variable in a property. See http://commons.apache.org/configuration/userguide/howto_basicfeatures.html#V... Good thing is that both commons-configuration and l10n are based on java standard Properties and also that it's the same syntax as other tools to describe properties variable (Maven, Ant, ...) which make it almost a standard. The idea would be that instead of finding if the returned string is a key or not we would see it as a value that can contain variable and which would generally be just the variable. For example we could return "${rendering.macro.include.parameter.document.description}" as include macro "document" field description.
WDYT ?
Thanks, -- Thomas Mortagne
-- Thomas Mortagne
Hi guys Just wanted you to know that, in OW2, we have a substitution engine (called interpolator in commons-lang) that handles property substitution nicely. Syntax of the property is configurable (${} / #[] / ...), tree based property resolution (${hello.${me}}), recursive substitution (if a resolved property value contains another property) are supported... It's also easily extensible (you can bind a resolver to any source). Let me know if you want more informations... The module source: http://websvn.ow2.org/listing.php?repname=easybeans&path=%2Ftrunk%2Futil%2Fm... Usage example: http://websvn.ow2.org/filedetails.php?repname=easybeans& path=%2Ftrunk%2Futil%2Fmodules%2Fsubstitution%2Fsrc%2Ftest%2Fjava%2Forg%2Fow2%2Futil%2Fsubstitution%2Ftest%2FDefaultSubstitutionEngineTestCase.java --Guillaume Le 20/04/2010 17:35, Thomas Mortagne a écrit :
macro "document" field description.
On Tue, Apr 20, 2010 at 19:00, Guillaume Sauthier <Guillaume.Sauthier@objectweb.org> wrote:
Hi guys
Just wanted you to know that, in OW2, we have a substitution engine (called interpolator in commons-lang) that handles property substitution nicely. Syntax of the property is configurable (${} / #[] / ...), tree based property resolution (${hello.${me}}), recursive substitution (if a resolved property value contains another property) are supported... It's also easily extensible (you can bind a resolver to any source).
Sounds good i will definitely adding it to my list of things to look at for new l10n module and rendering needs. But i don't know when since i'm not really actively working on it right now, i sent previous mail to have it written somewhere to not forget about the idea ;)
Let me know if you want more informations...
The module source: http://websvn.ow2.org/listing.php?repname=easybeans&path=%2Ftrunk%2Futil%2Fm...
Usage example: http://websvn.ow2.org/filedetails.php?repname=easybeans& path=%2Ftrunk%2Futil%2Fmodules%2Fsubstitution%2Fsrc%2Ftest%2Fjava%2Forg%2Fow2%2Futil%2Fsubstitution%2Ftest%2FDefaultSubstitutionEngineTestCase.java
--Guillaume
Le 20/04/2010 17:35, Thomas Mortagne a écrit :
macro "document" field description.
_______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Le 20/04/2010 19:18, Thomas Mortagne a écrit :
On Tue, Apr 20, 2010 at 19:00, Guillaume Sauthier <Guillaume.Sauthier@objectweb.org> wrote:
Hi guys
Just wanted you to know that, in OW2, we have a substitution engine (called interpolator in commons-lang) that handles property substitution nicely. Syntax of the property is configurable (${} / #[] / ...), tree based property resolution (${hello.${me}}), recursive substitution (if a resolved property value contains another property) are supported... It's also easily extensible (you can bind a resolver to any source).
Sounds good i will definitely adding it to my list of things to look at for new l10n module and rendering needs. But i don't know when since i'm not really actively working on it right now, i sent previous mail to have it written somewhere to not forget about the idea ;)
Glad to hear that it could be useful to someone else :) --G
Let me know if you want more informations...
The module source: http://websvn.ow2.org/listing.php?repname=easybeans&path=%2Ftrunk%2Futil%2Fm...
Usage example: http://websvn.ow2.org/filedetails.php?repname=easybeans& path=%2Ftrunk%2Futil%2Fmodules%2Fsubstitution%2Fsrc%2Ftest%2Fjava%2Forg%2Fow2%2Futil%2Fsubstitution%2Ftest%2FDefaultSubstitutionEngineTestCase.java
--Guillaume
Le 20/04/2010 17:35, Thomas Mortagne a écrit :
macro "document" field description.
_______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
participants (3)
-
Guillaume Sauthier -
Thomas Mortagne -
Vincent Massol