The Substitute task is to be used to search for keys in
a file and replace those keys with their equivalent
values. The key-value pairs are to be defined in
hierarchical external property files (resource bundle
files).
The Substitute task must be encoding aware. One should
be able to specify encoding schemes for the source files,
destination files as well as the resource bundle file.
Use Case:
=========
Java programs that support Internationalization very often
use ResourceBundles in code to lookup text specific to
a language at runtime. Some folks just maintain different internationalized
versions of the same java
program. While the first approach has to face the
decreased performance because of the number of lookups
involved at runtime, the second approach is a
maintenance nightmare. In such cases, people turn to a
third approach: to use keys in the program that can be
replaced with internationalized values at compile time,
thereby creating multiple versions of internationalized
code while maintaining only one set of code. This
approach is useful in JSP/HTML programming also -
using a template file to build actual equivalent
internationalized files.
Since this is a task typically carried out at compile-
time, it will be a nice addition to Ant's tasks.
I am working on building such a task currently. I will
send it as soon as I wrap it up.
Example:
<substitute toDir="tmp/ja"
starttoken="$"
endtoken="$"
bundle="resource/BaseResource"
bundlelanguage="ja"
forceoverwrite="yes"
srcencoding="ISO8859_1"
destencoding="SJIS"
bundleencoding="SJIS">
<fileset dir=".">
<include name="**/*.jsp"/>
</fileset>
</substitute>
<substitute toDir="tmp/fr"
starttoken="#"
endtoken="#"
bundle="resource/BaseResource"
bundlelanguage="fr"
srcencoding="ISO8859_1">
<fileset dir=".">
<include name="**/*.jsp"/>
</fileset>
</substitute>
Thanks,
Magesh