You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

translate.html 6.3 KiB

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