Cari di Apache Ant 
    Apache Ant User Manual
Daftar Isi
(Sebelumnya) TouchTruncate (Berikutnya)
Apache Ant Tasks

Translate

Translate

Description

Identifies keys in files delimited by special tokensand translates them with values read from resource bundles.

A resource bundle contains locale-specific key-value pairs.A resource bundle is a hierarchical set of property files.A bundle name makes up its base family name. Each file thatmakes up this bundle has this name plus its locale. For example,if the resource bundle name is MyResources, the file that containsGerman text will take the name MyResources_de. In addition tolanguage, country and variant are also used to form the files inthe bundle.

The resource bundle lookup searches for resource files with varioussuffixes on the basis of (1) the desired locale and (2) the defaultlocale (basebundlename), in the following order from lower-level(more specific) to parent-level (less specific):

basebundlename + "_" + language1 + "_" + country1 + "_" + variant1basebundlename + "_" + language1 + "_" + country1basebundlename + "_" + language1basebundlenamebasebundlename + "_" + language2 + "_" + country2 + "_" + variant2basebundlename + "_" + language2 + "_" + country2basebundlename + "_" + language2

The file names generated thus are appended with the string ".properties"to make up the file names that are to be used.

File encoding is supported. The encoding scheme of the source files,destination files and the bundle files can be specified.Destination files can be explicitly overwritten using theforceoverwrite attribute. If forceoverwriteis false, the destination file is overwritten only if either thesource file or any of the files that make up the bundle have beenmodified after the destination file was last modified.

New in Apache Ant 1.6:
Line endings of source files are preserved in the translated files.

FileSets are used to select files totranslate.

Parameters

Attribute Description Required
todir Destination directory where destination files are to be created. Yes
starttoken The starting token to identify keys. Yes
endtoken The ending token to identify keys. Yes
bundle Family name of resource bundle. Yes
bundlelanguage Locale specific language of resource bundle. Defaults to default locale's language. No
bundlecountry Locale specific country of resource bundle. Defaults to default locale's country. No
bundlevariant Locale specific variant of resource bundle. Defaults to the default variant of the country and language being used. No
srcencoding Source file encoding scheme. Defaults to system default file encoding. No
destencoding Destination file encoding scheme. Defaults to source file encoding. No
bundleencoding Resource Bundle file encoding scheme. Defaults to source file encoding. No
forceoverwrite Overwrite existing files even if the destination files are newer. Defaults to "no". No

Parameters specified as nested elements

fileset

FileSets are used to select files that contain keys for which value translated files are to be generated.

Examples

Translate source file encoded in english into its japaneseequivalent using a resource bundle encoded in japanese.

  <translate toDir="$(dest.dir}/ja" starttoken="#" endtoken="#" bundle="resource/BaseResource" bundlelanguage="ja" forceoverwrite="yes" srcencoding="ISO8859_1" destencoding="SJIS" bundleencoding="SJIS"> <fileset dir="${src.dir}"> <include name="**/*.jsp"/> </fileset>  </translate>
(Sebelumnya) TouchTruncate (Berikutnya)