<
From version < 5.2 >
edited by Vincent Massol
on 2010/03/04
To version < 6.1 >
edited by Silvia Macovei
on 2010/03/04
>
Change comment: Document converted from syntax xwiki/1.0 to syntax xwiki/2.0

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.VincentMassol
1 +XWiki.SilviaRusu
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 1.0
1 +XWiki 2.0
Content
... ... @@ -1,62 +1,68 @@
1 -1 Writing Internationalized XWiki Applications
1 += Writing Internationalized XWiki Applications =
2 2  
3 -#toc("" "" "")
3 +{{toc start="" depth="" numbered=""/}}
4 4  
5 -1.1 Using the static Resource Bundles
5 +== Using the static Resource Bundles ==
6 6  
7 7  * Stop your XWiki instance
8 -* Unjar the <tt>WEB-INF/lib/xwiki-core-\*.jar</tt> file (it was named <tt>xwiki.jar</tt> in old versions) in <tt>WEB-INF/classes</tt> and remove it from <tt>WEB-INF/lib</tt>
9 -* Edit the <tt>WEB-INF/classes/ApplicationResources*.properties</tt> Resource Bundle files by adding the key/value pairs you need for your application.
8 +* 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##
9 +* Edit the ##WEB-INF/classes/ApplicationResources*.properties## Resource Bundle files by adding the key/value pairs you need for your application.
10 10  * In your document, use the following to get the value associated with a key:
11 11  
12 -{code}
12 +{{code}}
13 13  $msg.get("key")
14 -{code}
14 +{{/code}}
15 15  
16 16  This will get the value from the Resource Bundle corresponding to the current language you are using in XWiki.
17 17  
18 -1.1 Using properties located in XWiki pages
18 +== Using properties located in XWiki pages ==
19 19  
20 -#warning("The features described below are only available in XWiki 1.0 Beta 4 and above. The ability to parametrize the resource string is available only in XWiki 1.0 Beta 5 and above.")
20 +{{warning}}
21 +The features described below are only available in XWiki 1.0 Beta 4 and above. The ability to parametrize the resource string is available only in XWiki 1.0 Beta 5 and above.
22 +{{/warning}}
21 21  
22 22  * Create a page that will host your key/value pairs.
23 23  * Enter all the key/value pairs in that page (use the wiki editor). For example:
24 24  
25 -{code}
27 +{{code}}
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 -{code}
31 +{{/code}}
30 30  
31 31  * Do the same for all the translations you want.
32 32  
33 -#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.")
35 +{{info}}
36 +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.
37 +{{/info}}
34 34  
35 35  * Tell XWiki that your page is a Document Bundle by going to the Administration page, selecting the "Programming" icon and entering it in the "Internationalization Document Bundles" field. You can specify several pages, separated by commas.
36 36  
37 -#info("When creating \"Internationalization Document Bundles\", you should avoid naming the pages with names that include spaces. For example, a document name of Main.My Messages could cause issues, instead, use Main.MyMessages")
41 +{{info}}
42 +When creating
43 +{{/info}}
38 38  
39 -* Alternatively you can also specify the list of Internationalization Document Bundles in <tt>xwiki.cfg</tt> under the key <tt>xwiki.documentBundles</tt>.
40 -
45 +* Alternatively you can also specify the list of Internationalization Document Bundles in ##xwiki.cfg## under the key ##xwiki.documentBundles##.
41 41  * On the page where you want to use the internationalized message, use:
42 42  
43 -{code}
48 +{{code}}
44 44  $msg.get("key")
45 45  $msg.get("key", ["param1", "param2", ...])
46 -{code}
51 +{{/code}}
47 47  
48 -where <tt>key</tt> is the key for the message to retrieve. Parameters can also be passed as is shown in the second syntax above.
53 +where ##key## is the key for the message to retrieve. Parameters can also be passed as is shown in the second syntax above.
49 49  
50 -1.1 I18n of XWiki Objects
55 +== I18n of XWiki Objects ==
51 51  
52 -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:
57 +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:
58 +
53 53  * 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).
54 54  * Use Velocity scripting to do an IF in your object. For example, you could have:
55 -{code:none}
61 +
62 +{{code language="none"}}
56 56  #if ($context.language == "fr")
57 57   French texts
58 58  #else
59 59   Default texts
60 60  #end
61 -{code}
62 -
68 +{{/code}}
XWiki.XWikiComments[0]
Comment
... ... @@ -1,2 +1,1 @@
1 -How to distinguish diffrent language by "Using properties located in XWiki pages"?
2 -
1 +How to distinguish diffrent language by "Using properties located in XWiki pages"?
XWiki.XWikiComments[1]
Comment
... ... @@ -1,5 +1,5 @@
1 -The procedure for "Using properties located in XWiki pages" lacks information:
1 +The procedure for "Using properties located in XWiki pages" lacks information: {{velocity filter="none"}}{{html clean="false" wiki="true"}}
2 2  * How would I distinguish between different languages? Is there a naming convention for the pages (like "de", "en" ...)?
3 3  * Would I create a single page for key/value pairs and translate that to the other languages I want, or are there separate documents for each language?
4 -* How exactly would I access the keys, e.g. $msg.get("<space>.<my language page>.<key>")?
5 -
4 +* How exactly would I access the keys, e.g. {{html clean="false"}}$msg.get("<space>.<my language page>.<key>"){{/html}}?
5 +{{/html}}{{/velocity}}

Get Connected