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 5.6 KiB

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