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