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

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