3 Ant utilities to help with internationalisation of Jalview.
4 Require the additional antcontrib targets (jar file).
6 <project name="jalviewLang" default="checkLang" basedir="..">
8 <taskdef resource="net/sf/antcontrib/antcontrib.properties">
10 <pathelement location="${basedir}/utils/ant-contrib-1.0b3.jar"/>
13 <taskdef resource="net/sf/antcontrib/antlib.xml">
15 <pathelement location="${basedir}/utils/ant-contrib-1.0b3.jar"/>
19 <target name="checkLang" description="Reports missing entries in language bundles compared to Message.properties">
20 <!-- adapted from http://stackoverflow.com/questions/14381660/ant-task-to-compare-two-properties-files -->
21 <!-- reduce logging level so 'reportMissingProperty' does not clutter up the output -->
22 <script language="javascript">
23 var logger = project.getBuildListeners( ).firstElement( );
24 logger.setMessageOutputLevel( 1 );
26 <foreach target="compareBundles" param="file2">
28 <fileset dir="${basedir}/resources/lang">
29 <exclude name="Messages.properties" />
35 <target name="compareBundles" description="compare a properties file with Messages.properties and vice versa">
37 <echo message="Missing message labels in ${file2} compared to Messages.properties"/>
38 <antcall target="compareProperties">
39 <param name="file1" value="resources/lang/Messages.properties"/>
40 <param name="file2" value="${file2}" />
43 <echo message="Missing message labels in Messages.properties compared to ${file2}"/>
44 <antcall target="compareProperties">
45 <param name="file2" value="resources/lang/Messages.properties"/>
46 <param name="file1" value="${file2}" />
50 <target name="compareProperties" description="reports missing entries in one message bundle">
51 <loadproperties srcFile="${file1}" prefix="prefixfile1"/>
52 <loadproperties srcFile="${file2}" prefix="prefixfile2"/>
54 <propertyselector property="file1.list" delimiter="," match="prefixfile1\.(.+)" select="\1"/>
55 <propertyselector property="file2.list" delimiter="," match="prefixfile2\.(.+)" select="\1"/>
57 <for list="${file1.list}" param="file1.property">
61 <matches pattern=",@{file1.property}," string=",${file2.list}," />
64 <property name="some_missing" value="true"/>
65 <antcall target="reportMissingProperty">
66 <param name="textLabel" value="@{file1.property}"/>
67 <param name="prefixedPropertyName" value="prefixfile1.@{file1.property}" />
75 <isset property="some_missing"/>
78 <echo>No labels missing :-)</echo>
83 <target name="reportMissingProperty" description="double dereference 'prefixedPropertyName' and report missing language property">
84 <propertycopy name="textValue" from="${prefixedPropertyName}"/>
85 <!-- output the property name (message label) and value (English text) -->
86 <echo message="${textLabel}=${textValue}"/>