JAL-2055 removed stub first version of colours
[jalview.git] / utils / i18nAnt.xml
1 <?xml version="1.0"?>
2 <!--
3   Ant utilities to help with internationalisation of Jalview.
4   Require the additional antcontrib targets (jar file).
5 -->
6 <project name="jalviewLang" default="checkLang" basedir="..">
7
8 <taskdef resource="net/sf/antcontrib/antcontrib.properties">
9   <classpath>
10     <pathelement location="${basedir}/utils/ant-contrib-0.3.jar"/>
11   </classpath>
12 </taskdef>
13 <taskdef resource="net/sf/antcontrib/antlib.xml"/>
14  
15 <target name="checkLang" description="Reports missing entries in language bundles compared to Message.properties">
16         <!-- adapted from http://stackoverflow.com/questions/14381660/ant-task-to-compare-two-properties-files -->
17         <!-- reduce logging level so 'reportMissingProperty' does not clutter up the output -->
18         <script language="javascript">
19         var logger = project.getBuildListeners( ).firstElement( );
20         logger.setMessageOutputLevel( 1 );
21     </script>
22         <echo message="Missing message labels compared to Messages.properties"/>
23         <foreach target="compareProperties" param="file2">
24                 <path>
25                         <fileset dir="${basedir}/resources/lang">
26                                 <exclude name="Messages.properties" />
27                         </fileset>
28                 </path>
29         </foreach>
30 </target>
31
32 <target name="compareProperties" description="reports missing entries in one message bundle">
33     <loadproperties srcFile="resources/lang/Messages.properties" prefix="prefixfile1"/>
34     <loadproperties srcFile="${file2}" prefix="prefixfile2"/>
35
36     <propertyselector property="file1.list" delimiter="," match="prefixfile1\.(.+)" select="\1"/>
37     <propertyselector property="file2.list" delimiter="," match="prefixfile2\.(.+)" select="\1"/>
38         
39         <echo message=" "/>
40         <echo message="*** ${file2}:" />
41     <for list="${file1.list}" param="file1.property">
42         <sequential>
43             <if>
44                 <not>
45                     <matches pattern=",@{file1.property}," string=",${file2.list}," />
46                 </not>
47                 <then>
48                     <property name="some_missing" value="true"/>
49                         <antcall target="reportMissingProperty">
50                                 <param name="textLabel" value="@{file1.property}"/>
51                                 <param name="prefixedPropertyName" value="prefixfile1.@{file1.property}" />
52                         </antcall>
53                 </then>
54             </if>
55         </sequential>
56     </for>
57     <if>
58         <not>
59             <isset property="some_missing"/>
60         </not>
61         <then>
62                 <echo>No labels missing :-)</echo>
63         </then>
64     </if>
65 </target>
66
67 <target name="reportMissingProperty" description="double dereference 'prefixedPropertyName' and report missing language property">
68         <propertycopy name="textValue" from="${prefixedPropertyName}"/>
69         <!-- output the property name (message label) and value (English text) -->
70     <echo message="${textLabel}=${textValue}"/>
71 </target>
72
73 </project>