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