* Build: Don't update the po files by default, add new

target "poupdate" to do that.
This commit is contained in:
zzz
2009-11-18 14:16:36 +00:00
parent 74aa84b183
commit 56e0c3e047
3 changed files with 77 additions and 37 deletions

View File

@ -89,6 +89,24 @@
<!-- jar again to get the latest messages_*.class files --> <!-- jar again to get the latest messages_*.class files -->
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" /> <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
</target> </target>
<target name="poupdate" depends="compile">
<ant target="war" />
<!-- Update the messages_*.po files.
We need to supply the bat file for windows, and then change the fail property to true -->
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="cmd" osfamily="windows" failifexecutionfails="true" >
<arg value="/c" />
<arg value="bundle-messages.bat" />
<arg value="-p" />
</exec>
</target>
<target name="war" depends="precompilejsp"> <target name="war" depends="precompilejsp">
<!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ --> <!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
<war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml" <war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"

View File

@ -2,12 +2,22 @@
# Update messages_xx.po and messages_xx.class files, # Update messages_xx.po and messages_xx.class files,
# from both java and jsp sources. # from both java and jsp sources.
# Requires installed programs xgettext, msgfmt, msgmerge, and find. # Requires installed programs xgettext, msgfmt, msgmerge, and find.
#
# usage:
# bundle-messages.sh (generates the resource bundle from the .po file)
# bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
#
# zzz - public domain # zzz - public domain
# #
CLASS=net.i2p.router.web.messages CLASS=net.i2p.router.web.messages
TMPFILE=build/javafiles.txt TMPFILE=build/javafiles.txt
export TZ=UTC export TZ=UTC
if [ "$1" = "-p" ]
then
POUPDATE=1
fi
# #
# generate strings/Countries.java from ../../../installer/resources/countries.txt # generate strings/Countries.java from ../../../installer/resources/countries.txt
# #
@ -37,8 +47,12 @@ do
LG=${i#../locale/messages_} LG=${i#../locale/messages_}
LG=${LG%.po} LG=${LG%.po}
# make list of java files newer than the .po file if [ "$POUPDATE" = "1" ]
find $JPATHS -name *.java -newer $i > $TMPFILE then
# make list of java files newer than the .po file
find $JPATHS -name *.java -newer $i > $TMPFILE
fi
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \ if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \ build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
! -s $TMPFILE ] ! -s $TMPFILE ]
@ -46,42 +60,46 @@ do
continue continue
fi fi
echo "Generating ${CLASS}_$LG ResourceBundle..." if [ "$POUPDATE" = "1" ]
then
echo "Updating the $i file from the tags..."
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# intl._("foo")
# intl.title("foo")
# handler._("foo")
# formhandler._("foo")
# net.i2p.router.web.Messages.getString("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \
--keyword=net.i2p.router.web.Messages.getString \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
fi
# extract strings from java and jsp files, and update messages.po files echo "Generating ${CLASS}_$LG ResourceBundle..."
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# intl._("foo")
# intl.title("foo")
# handler._("foo")
# formhandler._("foo")
# net.i2p.router.web.Messages.getString("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \
--keyword=net.i2p.router.web.Messages.getString \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java -r $CLASS -l $LG -d build/obj $i msgfmt --java -r $CLASS -l $LG -d build/obj $i

View File

@ -32,6 +32,7 @@
<echo message=" pkgWithDesktopgui: distclean then package everything up with the desktopgui" /> <echo message=" pkgWithDesktopgui: distclean then package everything up with the desktopgui" />
<echo message=" distWithDesktopgui: pkgWithDesktopgui and javadoc" /> <echo message=" distWithDesktopgui: pkgWithDesktopgui and javadoc" />
<echo message=" distcleanWithDesktopgui: clean up all derived files (including desktopgui files)" /> <echo message=" distcleanWithDesktopgui: clean up all derived files (including desktopgui files)" />
<echo message=" poupdate: update the .po files for translators" />
</target> </target>
<target name="debianhowto"> <target name="debianhowto">
<echo message="To build debian packages, you must run dpkg-buildpackage as root in the source directory. It will then run ant for you. dpkg-buildpackage is found in the 'dpkg-dev' package. Also it should work fine to use the 'fakeroot' package with dpkg-buildpackage, if you don't want to run as root. Please read 'man dpkg-buildpackage' before building any packages yourself." /> <echo message="To build debian packages, you must run dpkg-buildpackage as root in the source directory. It will then run ant for you. dpkg-buildpackage is found in the 'dpkg-dev' package. Also it should work fine to use the 'fakeroot' package with dpkg-buildpackage, if you don't want to run as root. Please read 'man dpkg-buildpackage' before building any packages yourself." />
@ -138,6 +139,9 @@
<copy file="installer/lib/jbigi/jbigi.jar" todir="build" /> <copy file="installer/lib/jbigi/jbigi.jar" todir="build" />
<copy file="apps/addressbook/dist/addressbook.war" todir="build/" /> <copy file="apps/addressbook/dist/addressbook.war" todir="build/" />
</target> </target>
<target name="poupdate">
<ant dir="apps/routerconsole/java/" target="poupdate" />
</target>
<target name="javadoc"> <target name="javadoc">
<mkdir dir="./build" /> <mkdir dir="./build" />
<mkdir dir="./build/javadoc" /> <mkdir dir="./build/javadoc" />