You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Marcel Stör <ma...@frightanic.com> on 2007/02/13 16:10:42 UTC
Load tokens from a file into list
I'd like to do some text substitution/translation in an XML file.
Source:
[...]
<!-- locale-token1 -->
[...]
<!-- locale-token2 -->
Target:
[...]
<foo locale="en">
<title>My title</title>
<description>My description</description>
</foo>
<foo locale="de">
<title>Mein Titel</title>
<description>Meine Beschreibung</description>
</foo>
[...]
On the file system I'd have resource files such as
resources_en.properties, resources_de.properties, etc. containing
key/value pairs for the tokens such as:
locale-token1.title = My title
locale-token1.description = My description
I thought I could implement this as a two-phase process:
1. replace each token with the basic XML structure. So, <!--
locale-token1 --> would then be replaced with
<foo locale="en">
<title>en.locale-token1.title</title>
<description>en.locale-token1.description</description>
</foo>
<foo locale="de">
<title>de.locale-token1.title</title>
<description>de.locale-token1.description</description>
</foo>
-> antcontrib foreach task
2. Replace all remaining tokens with the content of defined in the
corresponding resource files.
-> Ant replace task with properties files
Are there easier ways to achieve this? How would I parse my source file
in the first place to obtain a list of all tokens (to feed to the
foreach task)?
--
Marcel Stör, http://www.frightanic.com
Blog: http://frightanic.wordpress.com
Skype: marcelstoer
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org