Ticket #8645: exludeTransifexPlugins.patch

File exludeTransifexPlugins.patch, 6.1 KB (added by floscher, 22 months ago)

Patch to exclude plugins with a .tx/config file from being translated on Launchpad and only write the translations from Launchpad to plugins containing a data/ directory

  • i18n/build.xml

    diff --git a/i18n/build.xml b/i18n/build.xml
    index 7def4d5fc..cf6c945e0 100644
    a b  
    4444        </exec>
    4545        <copy file="specialmessages.java" todir="${i18n.build.dir}"/>
    4646    </target>
    47     <target name="po/josm.pot" description="Extracts message keys from the source code" depends="trans_.java,init">
     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&#xa;"></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">
    4869        <gettext-extract keysFile="josm.raw.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
    4970            <!-- core.port -->
    5071            <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
     
    5778            <fileset dir="${i18n.build.dir}" includes="trans_plugins.java"/>
    5879            <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> disable for now -->
    5980            <!-- plugins.pot -->
    60             <fileset dir="${plugin.dir}" includes="**/*.java"/>
     81            <fileset dir="${plugin.dir}" includesfile="${po.build.dir}/pluginSrc.txt"/>
    6182            <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/>
    6283            <fileset dir="${i18n.build.dir}" includes="trans_tag2link.java"/>
    6384        </gettext-extract>
     
    93114    </target>
    94115    <target name="po/plugins.pot" description="Extracts message keys from the plugins source code (minus core and data strings)" depends="trans_.java,po/core.pot,po/data.pot,init">
    95116        <gettext-extract keysFile="plugins.raw.pot" poDirectory="${i18n.build.dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
    96             <fileset dir="${plugin.dir}" includes="**/*.java"/>
     117            <fileset dir="${plugin.dir}" includesfile="${po.build.dir}/pluginSrc.txt"/>
    97118            <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/>
    98119            <fileset dir="${i18n.build.dir}" includes="trans_tag2link.java"/>
    99120        </gettext-extract>
     
    138159            <arg line="i18n.pl --potfile=po/data.pot --basedir=${i18n_data.install.dir}/ po/*.po"/>
    139160        </exec>
    140161    </target>
     162<!-- 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. -->
    141163    <target name="plugintrans">
    142164        <basename file="${path}" property="dir"/>
    143         <mkdir dir="${po.build.dir}/plugin_${dir}"/>
    144         <exec executable="perl" failonerror="true" output="${po.build.dir}/plugin_${dir}/trans_plugin.java">
    145             <arg line="convplugins.pl ${plugin.dir}/${dir}/build.xml"/>
    146         </exec>
    147         <gettext-extract keysFile="josm.pot" poDirectory="${po.build.dir}/plugin_${dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
    148             <fileset dir="${plugin.dir}/${dir}" includes="**/*.java"/>
    149             <fileset dir="${po.build.dir}/plugin_${dir}" includes="trans_*.java"/>
    150             <fileset dir="${i18n.build.dir}" includes="trans_${dir}.java"/> <!-- include plugin specific translation -->
    151         </gettext-extract>
    152165        <if>
    153             <available file="${po.build.dir}/plugin_${dir}/josm.pot"/>
     166            <and>
     167                <available file="${po.build.dir}/plugin_${dir}/josm.pot" type="file"/>
     168                <available file="${plugin.dir}/${dir}/data/" type="dir"/>
     169            </and>
    154170            <then>
     171                <mkdir dir="${po.build.dir}/plugin_${dir}"/>
     172                <exec executable="perl" failonerror="true" output="${po.build.dir}/plugin_${dir}/trans_plugin.java">
     173                    <arg line="convplugins.pl ${plugin.dir}/${dir}/build.xml"/>
     174                </exec>
     175                <gettext-extract keysFile="josm.pot" poDirectory="${po.build.dir}/plugin_${dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
     176                    <fileset dir="${plugin.dir}/${dir}" includes="**/*.java"/>
     177                    <fileset dir="${po.build.dir}/plugin_${dir}" includes="trans_*.java"/>
     178                    <fileset dir="${i18n.build.dir}" includes="trans_${dir}.java"/> <!-- include plugin specific translation -->
     179                </gettext-extract>
    155180                <exec executable="perl" failonerror="true">
    156181                    <arg line="i18n.pl --potfile=${po.build.dir}/plugin_${dir}/josm.pot --basedir=${plugin.dir}/${dir}/data/ po/*.po"/>
    157182                </exec>
     183                <delete dir="${po.build.dir}/plugin_${dir}"/>
    158184            </then>
    159185        </if>
    160         <delete dir="${po.build.dir}/plugin_${dir}"/>
    161186    </target>
    162187    <target name="clean">
    163188        <delete dir="${i18n.build.dir}"/>
     
    181206        <exec executable="perl" failonerror="true">
    182207            <arg line="launchpad.pl bzronly"/>
    183208        </exec>
    184         <antcall target="build"/>       
     209        <antcall target="build"/>
    185210    </target>
    186211    <target name="updatecore">
    187212        <exec executable="perl" failonerror="true">
    188213            <arg line="launchpad.pl bzronly"/>
    189214        </exec>
    190         <antcall target="buildcore"/>       
     215        <antcall target="buildcore"/>
    191216    </target>
    192217</project>