1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <project name="JOSM i18n" default="build" basedir=".">
|
---|
3 | <!-- compilation properties -->
|
---|
4 | <property name="josm.build.dir" value="../core"/>
|
---|
5 | <property name="josm.presets" value="${josm.build.dir}/resources/data/defaultpresets.xml"/>
|
---|
6 | <property name="plugin.dir" value="../plugins"/>
|
---|
7 | <property name="maps.srcfile" value="https://josm.openstreetmap.de/maps"/>
|
---|
8 | <property name="wiki.srcfile" value="https://josm.openstreetmap.de/josmfile?mode=en"/>
|
---|
9 | <property name="surveyor.srcfile" value="${plugin.dir}/surveyor/resources/surveyor.xml"/>
|
---|
10 | <property name="i18n.build.dir" value="build"/>
|
---|
11 | <property name="i18n.install.dir" value="${josm.build.dir}/resources/data"/>
|
---|
12 | <property name="pluginlist.install.dir" value="${josm.build.dir}/nodist/data/trans"/>
|
---|
13 | <property name="po.build.dir" value="${i18n.build.dir}"/>
|
---|
14 | <property name="ant.build.javac.target" value="1.5"/>
|
---|
15 | <property name="gettext.keywords" value="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"/>
|
---|
16 | <property name="gettexttasks.jar" value="lib/gettext-ant-tasks-0.9.7.jar"/>
|
---|
17 | <property name="antcontrib.jar" value="lib/ant-contrib-1.0b3.jar"/>
|
---|
18 | <property name="grand.jar" value="lib/grand-1.9.5.jar"/>
|
---|
19 | <target name="init" description="Loads the Ant gettext and contrib tasks">
|
---|
20 | <taskdef name="gettext-extract" classname="org.xnap.commons.ant.gettext.GettextExtractKeysTask" classpath="${gettexttasks.jar}"/>
|
---|
21 | <!-- for the <foreach> possibility -->
|
---|
22 | <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${antcontrib.jar}"/>
|
---|
23 | </target>
|
---|
24 | <target name="builddir">
|
---|
25 | <mkdir dir="${i18n.build.dir}"/>
|
---|
26 | </target>
|
---|
27 | <target name="trans_.java" depends="builddir">
|
---|
28 | <exec executable="perl" failonerror="true" logError="true" output="${i18n.build.dir}/trans_presets.java">
|
---|
29 | <arg line="convpreset.pl ${josm.presets}"/>
|
---|
30 | </exec>
|
---|
31 | <exec executable="perl" failonerror="true" logError="true" output="${i18n.build.dir}/trans_maps.java">
|
---|
32 | <arg line="convmaps.pl ${maps.srcfile}"/>
|
---|
33 | </exec>
|
---|
34 | <exec executable="perl" failonerror="true" logError="true" output="${i18n.build.dir}/trans_surveyor.java">
|
---|
35 | <arg line="convsurveyor.pl ${surveyor.srcfile}"/>
|
---|
36 | </exec>
|
---|
37 | <exec executable="perl" failonerror="true" logError="true" output="${i18n.build.dir}/trans_plugins.java">
|
---|
38 | <arg line="convplugins.pl ${plugin.dir}/*/build.xml"/>
|
---|
39 | </exec>
|
---|
40 | <exec executable="perl" failonerror="true">
|
---|
41 | <arg line="convwiki.pl ${wiki.srcfile} ${i18n.build.dir}/josmfiles ${i18n.build.dir}/josmfiles.zip"/>
|
---|
42 | </exec>
|
---|
43 | <copy file="specialmessages.java" todir="${i18n.build.dir}"/>
|
---|
44 | </target>
|
---|
45 | <!-- Create the file build/pluginSrc.txt, which contains a list of include patterns for all *.java files that should be translated relative to "${plugin.dir}" -->
|
---|
46 | <target name="filterpluginsources" depends="init">
|
---|
47 | <delete file="${po.build.dir}/pluginSrc.txt"/>
|
---|
48 | <foreach param="path" target="filterpluginsource">
|
---|
49 | <path>
|
---|
50 | <dirset dir="${plugin.dir}" includes="*" excludes="00_*" />
|
---|
51 | </path>
|
---|
52 | </foreach>
|
---|
53 | </target>
|
---|
54 | <!-- Helper task for `filterpluginsources`: Appends an include pattern to the file `build/pluginSrc.txt` if there is no file `.tx/config` for a plugin -->
|
---|
55 | <target name="filterpluginsource">
|
---|
56 | <if>
|
---|
57 | <not>
|
---|
58 | <available file="${path}/.tx/config" type="file" />
|
---|
59 | </not>
|
---|
60 | <then>
|
---|
61 | <basename file="${path}" property="dir"/>
|
---|
62 | <echo file="${po.build.dir}/pluginSrc.txt" append="true" message="${dir}/**/*.java
"></echo>
|
---|
63 | </then>
|
---|
64 | </if>
|
---|
65 | </target>
|
---|
66 | <target name="po/josm.pot" description="Extracts message keys from the source code" depends="trans_.java,init,filterpluginsources">
|
---|
67 | <gettext-extract keysFile="josm.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot">
|
---|
68 | <!-- core.pot -->
|
---|
69 | <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
|
---|
70 | <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
|
---|
71 | <fileset dir="${i18n.build.dir}" includes="trans_presets.java"/>
|
---|
72 | <fileset dir="${josm.build.dir}/resources/data/validator" includes="*.mapcss"/>
|
---|
73 | <fileset dir="${josm.build.dir}/resources/styles/standard" includes="*.mapcss"/>
|
---|
74 | <fileset dir="${i18n.build.dir}" includes="trans_maps.java"/>
|
---|
75 | <!-- data.pot -->
|
---|
76 | <fileset dir="${i18n.build.dir}" includes="trans_plugins.java"/>
|
---|
77 | <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> disable for now -->
|
---|
78 | <!-- plugins.pot -->
|
---|
79 | <fileset dir="${plugin.dir}" includesfile="${po.build.dir}/pluginSrc.txt"/>
|
---|
80 | <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/>
|
---|
81 | </gettext-extract>
|
---|
82 | </target>
|
---|
83 | <target name="po/core+maplist+presets.pot" depends="po/core.pot,po/maplist.pot,po/presets.pot">
|
---|
84 | <exec executable="msgcat" failonerror="true" output="po/core+maplist+presets.pot">
|
---|
85 | <arg line="po/core.pot po/maplist.pot po/presets.pot"/>
|
---|
86 | </exec>
|
---|
87 | </target>
|
---|
88 | <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="init">
|
---|
89 | <gettext-extract keysFile="core.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot">
|
---|
90 | <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
|
---|
91 | <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
|
---|
92 | <fileset dir="${josm.build.dir}/resources/data/validator" includes="*.mapcss"/>
|
---|
93 | <fileset dir="${josm.build.dir}/resources/styles/standard" includes="*.mapcss"/>
|
---|
94 | </gettext-extract>
|
---|
95 | </target>
|
---|
96 | <target name="po/maplist.pot" description="Extracts message keys from plugin descriptions" depends="trans_.java,init">
|
---|
97 | <gettext-extract keysFile="maplist.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot">
|
---|
98 | <!-- maps should be translated server-side, but that requires language file loading support in trac python code -->
|
---|
99 | <fileset dir="${i18n.build.dir}" includes="trans_maps.java"/>
|
---|
100 | </gettext-extract>
|
---|
101 | </target>
|
---|
102 | <target name="po/pluginlist.pot" description="Extracts message keys from plugin descriptions" depends="trans_.java,init">
|
---|
103 | <gettext-extract keysFile="pluginlist.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot">
|
---|
104 | <fileset dir="${i18n.build.dir}" includes="trans_plugins.java"/>
|
---|
105 | </gettext-extract>
|
---|
106 | </target>
|
---|
107 | <target name="po/presets.pot" description="Extracts message keys from presets (minus core)" depends="trans_.java,po/core.pot,init">
|
---|
108 | <gettext-extract keysFile="presets.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot --exclude-file=po/core.pot">
|
---|
109 | <fileset dir="${i18n.build.dir}" includes="trans_presets.java"/>
|
---|
110 | </gettext-extract>
|
---|
111 | </target>
|
---|
112 | <target name="po/plugins.pot" description="Extracts message keys from the plugins source code (minus core)" depends="trans_.java,po/core.pot,po/presets.pot,init,filterpluginsources">
|
---|
113 | <gettext-extract keysFile="plugins.pot" poDirectory="po" keywords="${gettext.keywords} --exclude-file=excludes.pot --exclude-file=po/core.pot --exclude-file=po/presets.pot">
|
---|
114 | <fileset dir="${plugin.dir}" includesfile="${po.build.dir}/pluginSrc.txt"/>
|
---|
115 | <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/>
|
---|
116 | </gettext-extract>
|
---|
117 | </target>
|
---|
118 | <target name="build">
|
---|
119 | <antcall target="buildcore"/>
|
---|
120 | <antcall target="buildplugins"/>
|
---|
121 | </target>
|
---|
122 | <target name="buildplugins" depends="init">
|
---|
123 | <foreach param="path" target="plugintrans" parallel="true" maxThreads="8">
|
---|
124 | <path>
|
---|
125 | <dirset dir="${plugin.dir}" includes="*" excludes="00_*" />
|
---|
126 | </path>
|
---|
127 | </foreach>
|
---|
128 | </target>
|
---|
129 | <target name="singleplugintrans" depends="init">
|
---|
130 | <antcall target="plugintrans">
|
---|
131 | <param name="path" value="${plugin}"/>
|
---|
132 | </antcall>
|
---|
133 | </target>
|
---|
134 | <target name="buildcore" depends="pot">
|
---|
135 | <antcall target="coretrans"/>
|
---|
136 | <antcall target="pluginlisttrans"/>
|
---|
137 | </target>
|
---|
138 | <target name="coretrans" depends="po/core+maplist+presets.pot">
|
---|
139 | <exec executable="perl" failonerror="true">
|
---|
140 | <arg line="i18n.pl --potfile=po/core+maplist+presets.pot --basedir=${i18n.install.dir}/ po/*.po"/>
|
---|
141 | </exec>
|
---|
142 | </target>
|
---|
143 | <target name="pluginlisttrans" depends="po/pluginlist.pot">
|
---|
144 | <exec executable="perl" failonerror="true">
|
---|
145 | <arg line="i18n.pl --potfile=po/pluginlist.pot --basedir=${pluginlist.install.dir}/ po/*.po"/>
|
---|
146 | </exec>
|
---|
147 | </target>
|
---|
148 | <!-- If the file `josm.pot` is present and the plugin has a `data/` directory, update its *.po files based on the ones in the `po/` directory. -->
|
---|
149 | <!-- If the plugin has a Transifex config file `.tx/config`, skip this target altogether -->
|
---|
150 | <target name="plugintrans">
|
---|
151 | <basename file="${path}" property="dir"/>
|
---|
152 | <if>
|
---|
153 | <available file="${plugin.dir}/${dir}/.tx/config" type="file"/>
|
---|
154 | <then>
|
---|
155 | <echo message="Skip plugin ${dir}, because it is translated with Transifex!"/>
|
---|
156 | </then>
|
---|
157 | <else>
|
---|
158 | <echo message="Run plugintrans target for plugin ${dir}" level="info"/>
|
---|
159 | <mkdir dir="${po.build.dir}/plugin_${dir}"/>
|
---|
160 | <exec executable="perl" failonerror="true" output="${po.build.dir}/plugin_${dir}/trans_plugin.java">
|
---|
161 | <arg line="convplugins.pl ${plugin.dir}/${dir}/build.xml"/>
|
---|
162 | </exec>
|
---|
163 | <gettext-extract keysFile="josm.pot" poDirectory="${po.build.dir}/plugin_${dir}" keywords="${gettext.keywords}">
|
---|
164 | <fileset dir="${plugin.dir}/${dir}" includes="**/*.java"/>
|
---|
165 | <fileset dir="${po.build.dir}/plugin_${dir}" includes="trans_*.java"/>
|
---|
166 | <fileset dir="${i18n.build.dir}" includes="trans_${dir}.java"/> <!-- include plugin specific translation -->
|
---|
167 | </gettext-extract>
|
---|
168 | <if>
|
---|
169 | <and>
|
---|
170 | <available file="${po.build.dir}/plugin_${dir}/josm.pot" type="file"/>
|
---|
171 | <available file="${plugin.dir}/${dir}/data/" type="dir"/>
|
---|
172 | </and>
|
---|
173 | <then>
|
---|
174 | <exec executable="perl" failonerror="true">
|
---|
175 | <arg line="i18n.pl --potfile=${po.build.dir}/plugin_${dir}/josm.pot --basedir=${plugin.dir}/${dir}/data/ po/*.po"/>
|
---|
176 | </exec>
|
---|
177 | </then>
|
---|
178 | </if>
|
---|
179 | <delete dir="${po.build.dir}/plugin_${dir}"/>
|
---|
180 | </else>
|
---|
181 | </if>
|
---|
182 | </target>
|
---|
183 | <target name="clean">
|
---|
184 | <delete dir="${i18n.build.dir}"/>
|
---|
185 | <delete file="build.dot"/>
|
---|
186 | <delete file="build.png"/>
|
---|
187 | <delete>
|
---|
188 | <fileset dir="po" includes="*.*~" defaultexcludes="false"/>
|
---|
189 | <fileset dir="po" includes="*.po" defaultexcludes="false"/>
|
---|
190 | <fileset dir="po" includes="*.pot" defaultexcludes="false"/>
|
---|
191 | </delete>
|
---|
192 | </target>
|
---|
193 | <target name="test" depends="pot">
|
---|
194 | <mkdir dir="${i18n.build.dir}/test"/>
|
---|
195 | <exec executable="perl" failonerror="true">
|
---|
196 | <arg line="i18n.pl --potfile=po/josm.pot --basedir=${i18n.build.dir}/test/ po/*.po"/>
|
---|
197 | </exec>
|
---|
198 | </target>
|
---|
199 | <target name="pot" depends="po/josm.pot" />
|
---|
200 | <target name="update">
|
---|
201 | <exec executable="perl" failonerror="true">
|
---|
202 | <arg line="launchpad.pl bzronly"/>
|
---|
203 | </exec>
|
---|
204 | <antcall target="build"/>
|
---|
205 | </target>
|
---|
206 | <target name="updatecore">
|
---|
207 | <exec executable="perl" failonerror="true">
|
---|
208 | <arg line="launchpad.pl bzronly"/>
|
---|
209 | </exec>
|
---|
210 | <antcall target="buildcore"/>
|
---|
211 | </target>
|
---|
212 | <target name="ant-dependencies">
|
---|
213 | <typedef resource="net/ggtools/grand/antlib.xml" classpath="${grand.jar}"/>
|
---|
214 | <grand output="build.dot" outputconfigprefix="grand"/>
|
---|
215 | <exec executable="dot">
|
---|
216 | <arg line="-Tpng -o build.png build.dot"/>
|
---|
217 | </exec>
|
---|
218 | </target>
|
---|
219 | </project>
|
---|