ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magesh Umasankar" <umag...@rediffmail.com>
Subject [SUBMIT] Translate - a useful task for i18n
Date Fri, 19 Oct 2001 23:47:46 GMT

This is a follow-up to the proposal located at 
http://marc.theaimsgroup.com/?l=ant-dev&m=100351914310132&w=2

The proposal identifies a use case for this task.

This task identifies keys in files delimited by special 
tokens and 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 that  makes up this bundle has this 
name plus its locale.  For example,  if the resource 
bundle name is MyResources, the file that contains
German text will take the name MyResources_de.  In
addition to language, country and variant are also used 
to form the files in the bundle.

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

basebundlename + "_" + language1 + "_" + country1 + "_" + variant1
basebundlename + "_" + language1 + "_" + country1
basebundlename + "_" + language1
basebundlename
basebundlename + "_" + language2 + "_" + country2 + "_" + variant2
basebundlename + "_" + language2 + "_" + country2
basebundlename + "_" + 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 exlicitly 
overwritten using the forceoverwrite attribute. If 
forceoverwrite is false, the destination file is 
overwritten only if either the source file or any of the 
files that make up the bundle have been modified after 
the destination file was last modified. 

FileSets are used to select files to translate. 

Supported attributes are:

* todir
* starttoken
* endtoken
* bundle
* bundlelanguage
* bundlecountry
* bundlevariant
* srcencoding
* destencoding
* bundleencoding and 
* foreceoverwrite

An example of how this task can be put to use:

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

Please find attached two files - Translate.java and
Translate.html

Thanks,
Magesh
 

Mime
View raw message