Issue Details (XML | Word | Printable)

Key: XWIKI-859
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vincent Massol
Reporter: Arnaud Thimel
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XWiki Core

Allow to specify parameters to the internationalisation/bundle system

Created: 14/Feb/07 10:10   Updated: 16/Feb/07 11:50
Component/s: Core
Affects Version/s: 1.0 B4
Fix Version/s: 1.0 B5

File Attachments: 1. Text File internat-20070214.diff.patch (5 kB)
2. Text File internat-20070215-2.diff.patch (7 kB)
3. Text File internat-20070215.diff.patch (8 kB)


Date of First Response: 15/Feb/07 08:51
Resolution Date: 16/Feb/07 11:50


 Description  « Hide
We need to pass parameters to a translation.

Exemple:
In the bundle document :
key=We have {0} new documents with {1} objects

In the wiki document :
$msg.get("key", "12", "3")
will render
We have 12 new documents with 3 objects



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Arnaud Thimel added a comment - 14/Feb/07 10:21
Attached a proposal of patch with a quick test.

The "get" method can handle up to 4 parameters which is the usual number of parameters


Arnaud Thimel added a comment - 15/Feb/07 03:07
Attached a second patch with list support :

Exemple :
$msg.get("key", ["12", "3"])

#set($list = ["12", "3"])
$msg.get("key", $list)

I left the normal (non-list) methods because they are more "user-friendly"


Vincent Massol added a comment - 15/Feb/07 08:51
Hi Arnaud,

I believe the implementation can be improved a lot. For example you don't seem to be using the standard and defacto way in Java, which is to use the MessageFormat class... This means your implementation doesn"t support all the nice features of MessageFormat. See http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html

Thanks
-Vincent


Arnaud Thimel added a comment - 15/Feb/07 14:45
attached a patch with string replacment using MessageFormat

Vincent Massol added a comment - 16/Feb/07 11:50