Last modified by Raphaƫl Jakse on 2022/03/17

From version 15.4
edited by Ecaterina Moraru (Valica)
on 2017/09/05
Change comment: There is no comment for this version
To version 18.1
edited by slauriere
on 2018/09/12
Change comment: A note about the Java MessageFormat syntax was added.

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,1 @@
1 -xwiki:Documentation.DevGuide.WebHome
1 +xwiki:Documentation.DevGuide.Tutorials.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.evalica
1 +XWiki.slauriere
Content
... ... @@ -4,7 +4,7 @@
4 4  
5 5  = Tutorials =
6 6  
7 -* [[Tutorial for Internationalizing a Form>>Documentation.DevGuide.TranslationsTutorial]]
7 +* [[Tutorial for Internationalizing a Form>>Documentation.DevGuide.Tutorials.TranslationsTutorial.WebHome]]
8 8  
9 9  = Using properties located in XWiki pages =
10 10  
... ... @@ -15,6 +15,8 @@
15 15  welcome=Welcome
16 16  withparams=I can {0} pass {1} {2} params too using the Java MessageFormat syntax
17 17  {{/code}}
18 +
19 +NB: the Java MessageFormat syntax is described in the [[MessageFormat Javadoc>>https://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html]]. There's in particular an important peculiarity for messages with parameters: single quotes need to be doubled to show up in the translated string, which is not the case for messages that are not parameterized.
18 18  )))
19 19  * Do the same for all the translations you want.(((
20 20  {{info}}
... ... @@ -36,7 +36,7 @@
36 36  $services.localization.render("key", ["param1", "param2", ...])
37 37  {{/code}}
38 38  
39 -where ##key## is the key for the message to retrieve. Parameters can also be passed as is shown in the second syntax above.
41 +where ##key## is the key for the message to retrieve. Parameters can also be passed as is shown in the second syntax above. Beware the parameters need to be passed as an array, not a plain String even if there's only one parameter: {{code}}$services.localization.render("key", ["param1"]){{/code}}.
40 40  )))
41 41  
42 42  == Old way ==

Get Connected