source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/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: 5.7 KB
Line 
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
14and translates them with values read from resource bundles.
15</p>
16<p>
17A resource bundle contains locale-specific key-value pairs.
18A resource bundle is a hierarchical set of property files.
19A bundle name makes up its base family name. Each file that
20makes up this bundle has this name plus its locale. For example,
21if the resource bundle name is MyResources, the file that contains
22German text will take the name MyResources_de. In addition to
23language, country and variant are also used to form the files in
24the bundle.
25</p>
26<p>
27The resource bundle lookup searches for resource files with various
28suffixes on the basis of (1) the desired locale and (2) the default
29locale (basebundlename), in the following order from lower-level
30(more specific) to parent-level (less specific):
31</p>
32<pre>
33basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1 + &quot;_&quot; + variant1
34basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1
35basebundlename + &quot;_&quot; + language1
36basebundlename
37basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2 + &quot;_&quot; + variant2
38basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2
39basebundlename + &quot;_&quot; + language2
40</pre>
41<p>
42The file names generated thus are appended with the string &quot;.properties&quot;
43to make up the file names that are to be used.
44</p>
45<p>
46File encoding is supported. The encoding scheme of the source files,
47destination files and the bundle files can be specified.
48
49Destination files can be explicitly overwritten using the
50<var>forceoverwrite</var> attribute. If <var>forceoverwrite</var>
51is false, the destination file is overwritten only if either the
52source file or any of the files that make up the bundle have been
53modified after the destination file was last modified.
54</p>
55<p>
56<em>New in Ant 1.6:</em><br/>
57Line 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
60translate.
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 &quot;no&quot;.</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
147equivalent using a resource bundle encoded in japanese.
148</b></p>
149<pre>
150 &lt;translate toDir=&quot;$(dest.dir}/ja&quot;
151 starttoken=&quot;#&quot;
152 endtoken=&quot;#&quot;
153 bundle=&quot;resource/BaseResource&quot;
154 bundlelanguage=&quot;ja&quot;
155 forceoverwrite=&quot;yes&quot;
156 srcencoding=&quot;ISO8859_1&quot;
157 destencoding=&quot;SJIS&quot;
158 bundleencoding=&quot;SJIS&quot;&gt;
159 &lt;fileset dir=&quot;${src.dir}&quot;&gt;
160 &lt;include name=&quot;**/*.jsp&quot;/&gt;
161 &lt;/fileset&gt;
162 &lt;/translate&gt;
163</pre>
164<hr>
165<p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation. All rights
166Reserved.</p>
167</body>
168</html>
Note: See TracBrowser for help on using the repository browser.