source: release-kits/lirk3/bin/ant-installer/web/manual/manual/OptionalTasks/translate.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 6.3 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>Translate Task</title>
23</head>
24
25<body>
26
27<h2><a name="translate">Translate</a></h2>
28<h3>Description</h3>
29<p>Identifies keys in files delimited by special tokens
30and translates them with values read from resource bundles.
31</p>
32<p>
33A resource bundle contains locale-specific key-value pairs.
34A resource bundle is a hierarchical set of property files.
35A bundle name makes up its base family name. Each file that
36makes up this bundle has this name plus its locale. For example,
37if the resource bundle name is MyResources, the file that contains
38German text will take the name MyResources_de. In addition to
39language, country and variant are also used to form the files in
40the bundle.
41</p>
42<p>
43The resource bundle lookup searches for resource files with various
44suffixes on the basis of (1) the desired locale and (2) the default
45locale (basebundlename), in the following order from lower-level
46(more specific) to parent-level (less specific):
47</p>
48<pre>
49basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1 + &quot;_&quot; + variant1
50basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1
51basebundlename + &quot;_&quot; + language1
52basebundlename
53basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2 + &quot;_&quot; + variant2
54basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2
55basebundlename + &quot;_&quot; + language2
56</pre>
57<p>
58The file names generated thus are appended with the string &quot;.properties&quot;
59to make up the file names that are to be used.
60</p>
61<p>
62File encoding is supported. The encoding scheme of the source files,
63destination files and the bundle files can be specified.
64
65Destination files can be explicitly overwritten using the
66<var>forceoverwrite</var> attribute. If <var>forceoverwrite</var>
67is false, the destination file is overwritten only if either the
68source file or any of the files that make up the bundle have been
69modified after the destination file was last modified.
70</p>
71<p>
72<em>New in Ant 1.6:</em><br>
73Line endings of source files are preserved in the translated files.
74</p>
75<p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select files to
76translate.
77</p>
78<h3>Parameters</h3>
79<table border="1" cellpadding="2" cellspacing="0">
80 <tr>
81 <td valign="top"><b>Attribute</b></td>
82 <td valign="top"><b>Description</b></td>
83 <td align="center" valign="top"><b>Required</b></td>
84 </tr>
85 <tr>
86 <td valign="top">todir</td>
87 <td valign="top">Destination directory where destination files are
88 to be created.</td>
89 <td valign="top" align="center">Yes</td>
90 </tr>
91 <tr>
92 <td valign="top">starttoken</td>
93 <td valign="top">The starting token to identify keys.</td>
94 <td valign="top" align="center">Yes</td>
95 </tr>
96 <tr>
97 <td valign="top">endtoken</td>
98 <td valign="top">The ending token to identify keys.</td>
99 <td valign="top" align="center">Yes</td>
100 </tr>
101 <tr>
102 <td valign="top">bundle</td>
103 <td valign="top">Family name of resource bundle.</td>
104 <td valign="top" align="center">Yes</td>
105 </tr>
106 <tr>
107 <td valign="top">bundlelanguage</td>
108 <td valign="top">
109 Locale specific language of resource bundle. Defaults to
110 default locale's language.
111 </td>
112 <td valign="top" align="center">No</td>
113 </tr>
114 <tr>
115 <td valign="top">bundlecountry</td>
116 <td valign="top">
117 Locale specific country of resource bundle. Defaults to
118 default locale's country.
119 </td>
120 <td valign="top" align="center">No</td>
121 </tr>
122 <tr>
123 <td valign="top">bundlevariant</td>
124 <td valign="top">
125 Locale specific variant of resource bundle. Defaults to
126 the default variant of the country and language being used.
127 </td>
128 <td valign="top" align="center">No</td>
129 </tr>
130 <tr>
131 <td valign="top">srcencoding</td>
132 <td valign="top">Source file encoding scheme. Defaults to
133 system default file encoding.</td>
134 <td valign="top" align="center">No</td>
135 </tr>
136 <tr>
137 <td valign="top">destencoding</td>
138 <td valign="top">Destination file encoding scheme. Defaults to
139 source file encoding.</td>
140 <td valign="top" align="center">No</td>
141 </tr>
142 <tr>
143 <td valign="top">bundleencoding</td>
144 <td valign="top">Resource Bundle file encoding scheme. Defaults to
145 source file encoding.</td>
146 <td valign="top" align="center">No</td>
147 </tr>
148 <tr>
149 <td valign="top">forceoverwrite</td>
150 <td valign="top">Overwrite existing files even if the destination
151 files are newer. Defaults to &quot;no&quot;.</td>
152 <td valign="top" align="center">No</td>
153 </tr>
154</table>
155<h3>Parameters specified as nested elements</h3>
156
157<h4>fileset</h4>
158 <p><a href="../CoreTypes/fileset.html">FileSets</a> are used to select files that
159 contain keys for which value translated files are to be generated.
160</p>
161<h3>Examples</h3>
162<p><b>Translate source file encoded in english into its japanese
163equivalent using a resource bundle encoded in japanese.
164</b></p>
165<pre>
166 &lt;translate toDir=&quot;$(dest.dir}/ja&quot;
167 starttoken=&quot;#&quot;
168 endtoken=&quot;#&quot;
169 bundle=&quot;resource/BaseResource&quot;
170 bundlelanguage=&quot;ja&quot;
171 forceoverwrite=&quot;yes&quot;
172 srcencoding=&quot;ISO8859_1&quot;
173 destencoding=&quot;SJIS&quot;
174 bundleencoding=&quot;SJIS&quot;&gt;
175 &lt;fileset dir=&quot;${src.dir}&quot;&gt;
176 &lt;include name=&quot;**/*.jsp&quot;/&gt;
177 &lt;/fileset&gt;
178 &lt;/translate&gt;
179</pre>
180
181</body>
182</html>
Note: See TracBrowser for help on using the repository browser.