JAL-2808 feature filters held on FeatureRenderer, getColor(feature)
[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="compareBundles" 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="compareBundles" description="compare a properties file with Messages.properties and vice versa">
32         <echo message=" "/>
33         <echo message="Missing message labels in ${file2} compared to Messages.properties"/>
34         <antcall target="compareProperties">
35                 <param name="file1" value="resources/lang/Messages.properties"/>
36                 <param name="file2" value="${file2}" />
37         </antcall>
38         <echo message=" "/>
39         <echo message="Missing message labels in Messages.properties compare to ${file2}"/>
40         <antcall target="compareProperties">
41                 <param name="file2" value="resources/lang/Messages.properties"/>
42                 <param name="file1" value="${file2}" />
43         </antcall>
44 </target>
45                 
46 <target name="compareProperties" description="reports missing entries in one message bundle">
47     <loadproperties srcFile="${file1}" prefix="prefixfile1"/>
48     <loadproperties srcFile="${file2}" prefix="prefixfile2"/>
49
50     <propertyselector property="file1.list" delimiter="," match="prefixfile1\.(.+)" select="\1"/>
51     <propertyselector property="file2.list" delimiter="," match="prefixfile2\.(.+)" select="\1"/>
52         
53     <for list="${file1.list}" param="file1.property">
54         <sequential>
55             <if>
56                 <not>
57                     <matches pattern=",@{file1.property}," string=",${file2.list}," />
58                 </not>
59                 <then>
60                     <property name="some_missing" value="true"/>
61                         <antcall target="reportMissingProperty">
62                                 <param name="textLabel" value="@{file1.property}"/>
63                                 <param name="prefixedPropertyName" value="prefixfile1.@{file1.property}" />
64                         </antcall>
65                 </then>
66             </if>
67         </sequential>
68     </for>
69     <if>
70         <not>
71             <isset property="some_missing"/>
72         </not>
73         <then>
74                 <echo>No labels missing :-)</echo>
75         </then>
76     </if>
77 </target>
78
79 <target name="reportMissingProperty" description="double dereference 'prefixedPropertyName' and report missing language property">
80         <propertycopy name="textValue" from="${prefixedPropertyName}"/>
81         <!-- output the property name (message label) and value (English text) -->
82     <echo message="${textLabel}=${textValue}"/>
83 </target>
84
85 </project>