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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Translate Task</title>
  20. </head>
  21. <body>
  22. <h2 id="translate">Translate</h2>
  23. <h3>Description</h3>
  24. <p>Identifies keys in files delimited by special tokens and translates them with values read from
  25. resource bundles.</p>
  26. <p>A resource bundle contains locale-specific key-value pairs. A resource bundle is a hierarchical
  27. set of property files. A bundle name makes up its base family name. Each file that makes up this
  28. bundle has this name plus its locale. For example, if the resource bundle name
  29. is <samp>MyResources</samp>, the file that contains German text will take the
  30. name <samp>MyResources_de</samp>. In addition to language, country and variant are also used to
  31. form the files in the bundle.</p>
  32. <p>The resource bundle lookup searches for resource files with various suffixes on the basis of (1)
  33. the desired locale and (2) the default locale (basebundlename), in the following order from
  34. lower-level (more specific) to parent-level (less specific):</p>
  35. <pre>
  36. basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1 + &quot;_&quot; + variant1
  37. basebundlename + &quot;_&quot; + language1 + &quot;_&quot; + country1
  38. basebundlename + &quot;_&quot; + language1
  39. basebundlename
  40. basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2 + &quot;_&quot; + variant2
  41. basebundlename + &quot;_&quot; + language2 + &quot;_&quot; + country2
  42. basebundlename + &quot;_&quot; + language2
  43. </pre>
  44. <p>The file names generated thus are appended with the string <samp>.properties</samp> to make up
  45. the file names that are to be used.</p>
  46. <p>File encoding is supported. The encoding scheme of the source files, destination files and the
  47. bundle files can be specified.</p>
  48. <p>Destination files can be explicitly overwritten using the <var>forceoverwrite</var> attribute.
  49. If <var>forceoverwrite</var> is <q>false</q>, the destination file is overwritten only if either the
  50. source file or any of the files that make up the bundle have been modified after the destination
  51. file was last modified.</p>
  52. <p><em>Since Apache Ant 1.6</em> line endings of source files are preserved in the translated
  53. files.</p>
  54. <p><a href="../Types/fileset.html">FileSet</a>s are used to select files to translate.</p>
  55. <h3>Parameters</h3>
  56. <table class="attr">
  57. <tr>
  58. <th scope="col">Attribute</th>
  59. <th scope="col">Description</th>
  60. <th scope="col">Required</th>
  61. </tr>
  62. <tr>
  63. <td>todir</td>
  64. <td>Destination directory where destination files are to be created.</td>
  65. <td>Yes</td>
  66. </tr>
  67. <tr>
  68. <td>starttoken</td>
  69. <td>The starting token to identify keys.</td>
  70. <td>Yes</td>
  71. </tr>
  72. <tr>
  73. <td>endtoken</td>
  74. <td>The ending token to identify keys.</td>
  75. <td>Yes</td>
  76. </tr>
  77. <tr>
  78. <td>bundle</td>
  79. <td>Family name of resource bundle.</td>
  80. <td>Yes</td>
  81. </tr>
  82. <tr>
  83. <td>bundlelanguage</td>
  84. <td>Locale specific language of resource bundle.</td>
  85. <td>No; defaults to default locale's language</td>
  86. </tr>
  87. <tr>
  88. <td>bundlecountry</td>
  89. <td>Locale specific country of resource bundle.</td>
  90. <td>No; defaults to default locale's country</td>
  91. </tr>
  92. <tr>
  93. <td>bundlevariant</td>
  94. <td>Locale specific variant of resource bundle.</td>
  95. <td>No; defaults to <var>bundlelanguage</var>_<var>bundlecountry</var></td>
  96. </tr>
  97. <tr>
  98. <td>srcencoding</td>
  99. <td>Source file encoding scheme.</td>
  100. <td>No; defaults to default JVM character encoding</td>
  101. </tr>
  102. <tr>
  103. <td>destencoding</td>
  104. <td>Destination file encoding scheme.</td>
  105. <td>No; defaults to <var>srcencoding</var></td>
  106. </tr>
  107. <tr>
  108. <td>bundleencoding</td>
  109. <td>Resource Bundle file encoding scheme.</td>
  110. <td>No; defaults to <var>srcencoding</var></td>
  111. </tr>
  112. <tr>
  113. <td>forceoverwrite</td>
  114. <td>Overwrite existing files even if the destination files are newer.</td>
  115. <td>No; defaults to <q>no</q></td>
  116. </tr>
  117. </table>
  118. <h3>Parameters specified as nested elements</h3>
  119. <h4>fileset</h4>
  120. <p><a href="../Types/fileset.html">FileSets</a> are used to select files that contain keys for which
  121. value translated files are to be generated.</p>
  122. <h3>Examples</h3>
  123. <p>Translate source file encoded in English into its Japanese equivalent using a resource bundle
  124. encoded in Japanese.</p>
  125. <pre>
  126. &lt;translate toDir=&quot;$(dest.dir}/ja&quot;
  127. starttoken=&quot;#&quot;
  128. endtoken=&quot;#&quot;
  129. bundle=&quot;resource/BaseResource&quot;
  130. bundlelanguage=&quot;ja&quot;
  131. forceoverwrite=&quot;yes&quot;
  132. srcencoding=&quot;ISO8859_1&quot;
  133. destencoding=&quot;SJIS&quot;
  134. bundleencoding=&quot;SJIS&quot;&gt;
  135. &lt;fileset dir=&quot;${src.dir}&quot;&gt;
  136. &lt;include name=&quot;**/*.jsp&quot;/&gt;
  137. &lt;/fileset&gt;
  138. &lt;/translate&gt;</pre>
  139. </body>
  140. </html>