Changes for page Writing Internationalized XWiki Applications
Last modified by Raphaƫl Jakse on 2022/03/17
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -4,10 +4,40 @@ 4 4 5 5 1.1 Using the static Resource Bundles 6 6 7 -TODO 7 +* Stop your XWiki instance 8 +* Unjar the ~~WEB-INF/lib/xwiki.jar~~ file in ~~WEB-INF/classes~~ and remove the ~~xwiki.jar~~file from ~~WEB-INF/lib~~ 9 +* Edit the ~~WEB-INF/classes/ApplicationResources*.properties~~ Resource Bundle files by adding the key/value pairs you need for your application. 10 +* In your document, use the following to get the value associated with a key: 8 8 12 +{code} 13 +$msg.get("key") 14 +{code} 15 + 16 +This will get the value from the Resource Bundle corresponding to the current language you are using in XWiki. 17 + 9 9 1.1 Using properties located in XWiki pages 10 10 11 11 #warning("The features described below are only available in XWiki 1.0 Beta 4 or above") 12 12 13 -TODO 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} 26 +greeting=hello 27 +welcome=Welcome 28 +{code} 29 + 30 +* Do the same for all the translations you want. 31 + 32 +#info("To enable multiple languages you'll need to go to the Administration page and set MultiLingual to true and list the different languages you wish to use in the Languages field.") 33 + 34 +* Tell XWiki that your page is a Document Bundle by going to the Administration page, selecting the Advanced tab and entering it in the "Internationalization Document Bundles" field. You can specify several pages, separated by commas. 35 + 36 +* On the page where you want to use the internationalized message, use: 37 + 38 +{code} 39 +$msg.get("key") 40 +{code} 41 + 42 +where ~~key~~ is the key for the message to retrieve. 43 +