JAL-1888 set verbosity and exclude the 'parallel' attribute so no parallel execution...
[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         <foreach target="compareProperties" param="file2">
23                 <path>
24                         <fileset dir="${basedir}/resources/lang">
25                                 <exclude name="Messages.properties" />
26                         </fileset>
27                 </path>
28         </foreach>
29 </target>
30
31 <target name="compareProperties" description="reports missing entries in one message bundle">
32     <loadproperties srcFile="resources/lang/Messages.properties" prefix="prefixfile1"/>
33     <loadproperties srcFile="${file2}" prefix="prefixfile2"/>
34
35     <propertyselector property="file1.list" delimiter="," match="prefixfile1\.(.+)" select="\1"/>
36     <propertyselector property="file2.list" delimiter="," match="prefixfile2\.(.+)" select="\1"/>
37         
38     <for list="${file1.list}" param="file1.property">
39         <sequential>
40             <if>
41                 <not>
42                     <matches pattern=",@{file1.property}," string=",${file2.list}," />
43                 </not>
44                 <then>
45                     <if>
46                         <not>
47                             <isset property="some_missing"/>
48                         </not>
49                             <then>
50                                 <echo message=" "/>
51                                 <echo>**** Missing in ${file2}: ****</echo>
52                             </then>
53                     </if>
54                     <property name="some_missing" value="true"/>
55                         <antcall target="reportMissingProperty">
56                                 <param name="textLabel" value="@{file1.property}"/>
57                                 <param name="prefixedPropertyName" value="prefixfile1.@{file1.property}" />
58                         </antcall>
59                 </then>
60             </if>
61         </sequential>
62     </for>
63 </target>
64
65 <target name="reportMissingProperty" description="double dereference 'prefixedPropertyName' and report missing language property">
66         <propertycopy name="textValue" from="${prefixedPropertyName}"/>
67         <!-- output the property name (message label) and value (English text) -->
68     <echo message="${textLabel}=${textValue}"/>
69 </target>
70
71 </project>