JAL-244 Allow adjusting Id column width in wrap mode. Set Id column width in gui...
[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-1.0b3.jar"/>
11   </classpath>
12 </taskdef>
13 <taskdef resource="net/sf/antcontrib/antlib.xml">
14   <classpath>
15     <pathelement location="${basedir}/utils/ant-contrib-1.0b3.jar"/>
16   </classpath>
17 </taskdef>
18  
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 );
25     </script>
26         <foreach target="compareBundles" param="file2">
27                 <path>
28                         <fileset dir="${basedir}/resources/lang">
29                                 <exclude name="Messages.properties" />
30                         </fileset>
31                 </path>
32         </foreach>
33 </target>
34
35 <target name="compareBundles" description="compare a properties file with Messages.properties and vice versa">
36         <echo message=" "/>
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}" />
41         </antcall>
42         <echo message=" "/>
43         <echo message="Missing message labels in Messages.properties compare to ${file2}"/>
44         <antcall target="compareProperties">
45                 <param name="file2" value="resources/lang/Messages.properties"/>
46                 <param name="file1" value="${file2}" />
47         </antcall>
48 </target>
49                 
50 <target name="compareProperties" description="reports missing entries in one message bundle">
51     <loadproperties srcFile="${file1}" prefix="prefixfile1"/>
52     <loadproperties srcFile="${file2}" prefix="prefixfile2"/>
53
54     <propertyselector property="file1.list" delimiter="," match="prefixfile1\.(.+)" select="\1"/>
55     <propertyselector property="file2.list" delimiter="," match="prefixfile2\.(.+)" select="\1"/>
56         
57     <for list="${file1.list}" param="file1.property">
58         <sequential>
59             <if>
60                 <not>
61                     <matches pattern=",@{file1.property}," string=",${file2.list}," />
62                 </not>
63                 <then>
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}" />
68                         </antcall>
69                 </then>
70             </if>
71         </sequential>
72     </for>
73     <if>
74         <not>
75             <isset property="some_missing"/>
76         </not>
77         <then>
78                 <echo>No labels missing :-)</echo>
79         </then>
80     </if>
81 </target>
82
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}"/>
87 </target>
88
89 </project>