Changes for page Writing Internationalized XWiki Applications
Last modified by Raphaƫl Jakse on 2022/03/17
From version 6.2
edited by Silvia Macovei
on 2010/03/04
on 2010/03/04
Change comment:
Fixed Title; Changed TOC; Fixed Inconsistencies
To version 6.3
edited by Vincent Massol
on 2010/03/04
on 2010/03/04
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. SilviaRusu1 +XWiki.VincentMassol - Content
-
... ... @@ -5,13 +5,13 @@ 5 5 * Stop your XWiki instance 6 6 * Unjar the ##WEB-INF/lib/xwiki-core-*.jar## file (it was named ##xwiki.jar## in old versions) in ##WEB-INF/classes## and remove it from ##WEB-INF/lib## 7 7 * Edit the ##WEB-INF/classes/ApplicationResources*.properties## Resource Bundle files by adding the key/value pairs you need for your application. 8 -* In your document, use the following to get the value associated with a key: 9 - 10 -{{code}} 8 +* In your document, use the following to get the value associated with a key:((( 9 +{{code language="none"}} 11 11 $msg.get("key") 12 12 {{/code}} 13 13 14 14 This will get the value from the Resource Bundle corresponding to the current language you are using in XWiki. 14 +))) 15 15 16 16 = Using properties located in XWiki pages = 17 17 ... ... @@ -20,14 +20,13 @@ 20 20 {{/warning}} 21 21 22 22 * Create a page that will host your key/value pairs. 23 -* Enter all the key/value pairs in that page (use the wiki editor). For example: 24 - 25 -{{code}} 23 +* Enter all the key/value pairs in that page (use the wiki editor). For example:((( 24 +{{code language="none"}} 26 26 greeting=hello 27 27 welcome=Welcome 28 28 withparams=I can {0} pass {1} {2} params too using the Java MessageFormat syntax 29 29 {{/code}} 30 - 29 +))) 31 31 * Do the same for all the translations you want. 32 32 33 33 {{info}} ... ... @@ -41,8 +41,7 @@ 41 41 {{/info}} 42 42 43 43 * Alternatively you can also specify the list of Internationalization Document Bundles in ##xwiki.cfg## under the key ##xwiki.documentBundles##. 44 -* On the page where you want to use the internationalized message, use: 45 - 43 +* On the page where you want to use the internationalized message, use:((( 46 46 {{code}} 47 47 $msg.get("key") 48 48 $msg.get("key", ["param1", "param2", ...]) ... ... @@ -49,6 +49,7 @@ 49 49 {{/code}} 50 50 51 51 where ##key## is the key for the message to retrieve. Parameters can also be passed as is shown in the second syntax above. 50 +))) 52 52 53 53 = I18n of XWiki Objects = 54 54 ... ... @@ -55,8 +55,7 @@ 55 55 This is currently not implemented (see our logged issue: [[XWIKI-69>>http://jira.xwiki.org/jira/browse/XWIKI-69]]). There are 2 workarounds you can use: 56 56 57 57 * Have several objects, one for each language, with a language field, and then decide which object to use (for example in a Class Sheet, based on the current language). 58 -* Use Velocity scripting to do an IF in your object. For example, you could have: 59 - 57 +* Use Velocity scripting to do an IF in your object. For example, you could have:((( 60 60 {{code language="none"}} 61 61 #if ($context.language == "fr") 62 62 French texts ... ... @@ -64,3 +64,4 @@ 64 64 Default texts 65 65 #end 66 66 {{/code}} 65 +)))