Externalizer

Externalizer is a directory based Ant task to externalize strings. The externalize process search all occurrences of a pattern defined string and externalize this string in a further file. The great advantage of the Externalizer is the scalability and extendability via modular structure. Smooth integration into Apache Ant gives an advantage to configure the Externalizer in an easy way.
The Externalizer can be used with all types of files or programming languages, f.e. php, java and so on. For each programming language you can define your own patterns to find strings, to substitute and to externalize them.

What's an ant task?

Apache Ant is a software tool for automating software build processes. It is similar to make but is written in the Java language and is primarily intended for use with Java. The most immediately noticeable difference between Ant and make is that Ant uses a file in XML format to describe the build process and its dependencies, whereas make has its own Makefile format. By default the XML file is named build.xml.
[Definition from wikipedia]

For each build process exists an ant task. Such a task is only a piece of code that can be executed. To get more informations about ant, visit: Apache Ant

Example: Externalize Strings in PHP

To externalize strings in your php code you have to create a similar ant task, like this:

<externalizer 
        pattern="_\(&quot;%string&quot;\)"
        substitution="(%label)" 
        labelMaxLength="80"
        labelPrefix="L_">

        <fileset dir="${src.dir}">
                <include name="test.txt" />
        </fileset>

        <externalizermodule 
                file="${messages.dir}/messages.txt"     
                pattern="define(&quot;%label&quot;, &quot;%string&quot;);"
                header="&lt;?php"
                footer="?&gt;"
        />
</externalizer>

This example externalize all strings like: _("%string") in the test.txt file and replace them with: (%label). %string and %label are tokens! The externalized strings will be written to the messages.txt with the following pattern: ("%label", "%string");

Before the Externalizer starts the test.txt could look like that:

test.txt

//Externalize string 
echo_("Header 1. Externalize this string");

//Externalize string with same text/labels
echo_("Same text");
echo_("Same text");

Afterwards the 2 files and could be look like this:

test.txt

//Externalize string 
echo(L_HEADER_1_EXTERNALIZE_THIS_STRING);

//Externalize string with same text/labels
echo(L_SAME_TEXT);
echo(L_SAME_TEXT);

messages.txt \

<?php
//Externalized Strings from 27.03.2006
define("L_HEADER_1_EXTERNALIZE_THIS_STRING", "Header 1. Externalize this string");
define("L_SAME_TEXT", "Same text");
?>