forked from I2P_Developers/i2p.i2p
Streaming: Bundle I2PSocketException messages for translation
This commit is contained in:
@ -271,6 +271,10 @@ trans.ru_RU = core/java/src/gnu/getopt/MessagesBundle_ru.properties
|
||||
trans.sk = core/java/src/gnu/getopt/MessagesBundle_sk.properties
|
||||
trans.zh_CN = core/java/src/gnu/getopt/MessagesBundle_zh.properties
|
||||
|
||||
[I2P.streaming]
|
||||
source_file = apps/ministreaming/locale/messages_en.po
|
||||
source_lang = en
|
||||
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
|
@ -19,7 +19,14 @@
|
||||
</classpath>
|
||||
</depend>
|
||||
</target>
|
||||
|
||||
<property name="javac.compilerargs" value="" />
|
||||
<property name="require.gettext" value="true" />
|
||||
|
||||
<condition property="no.bundle">
|
||||
<isfalse value="${require.gettext}" />
|
||||
</condition>
|
||||
|
||||
<target name="compile" depends="depend">
|
||||
<mkdir dir="./build" />
|
||||
<mkdir dir="./build/obj" />
|
||||
@ -62,7 +69,7 @@
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
|
||||
<target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
|
||||
<!-- set if unset -->
|
||||
<property name="workspace.changes.tr" value="" />
|
||||
<jar destfile="./build/mstreaming.jar" basedir="./build/obj" includes="**/*.class" >
|
||||
@ -89,6 +96,35 @@
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="bundle" depends="compile" unless="no.bundle">
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<env key="JAVA_HOME" value="${java.home}" />
|
||||
<arg value="./bundle-messages.sh" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="poupdate" depends="builddep, compile">
|
||||
<!-- Update the messages_*.po files. -->
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="javadoc">
|
||||
<mkdir dir="./build" />
|
||||
|
112
apps/ministreaming/java/bundle-messages.sh
Executable file
112
apps/ministreaming/java/bundle-messages.sh
Executable file
@ -0,0 +1,112 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Update messages_xx.po and messages_xx.class files,
|
||||
# from both java and jsp sources.
|
||||
# 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
|
||||
#
|
||||
CLASS=net.i2p.client.streaming.messages
|
||||
TMPFILE=build/javafiles.txt
|
||||
export TZ=UTC
|
||||
RC=0
|
||||
|
||||
if ! $(which javac > /dev/null 2>&1); then
|
||||
export JAVAC=${JAVA_HOME}/../bin/javac
|
||||
fi
|
||||
|
||||
if [ "$1" = "-p" ]
|
||||
then
|
||||
POUPDATE=1
|
||||
fi
|
||||
|
||||
# on windows, one must specify the path of commnad find
|
||||
# since windows has its own retarded version of find.
|
||||
if which find|grep -q -i windows ; then
|
||||
export PATH=.:/bin:/usr/local/bin:$PATH
|
||||
fi
|
||||
# Fast mode - update ondemond
|
||||
# set LG2 to the language you need in envrionment varibales to enable this
|
||||
|
||||
# add ../java/ so the refs will work in the po file
|
||||
JPATHS="../java/src"
|
||||
for i in ../locale/messages_*.po
|
||||
do
|
||||
# get language
|
||||
LG=${i#../locale/messages_}
|
||||
LG=${LG%.po}
|
||||
|
||||
# skip, if specified
|
||||
if [ $LG2 ]; then
|
||||
[ $LG != $LG2 ] && continue || echo INFO: Language update is set to [$LG2] only.
|
||||
fi
|
||||
|
||||
if [ "$POUPDATE" = "1" ]
|
||||
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/streaming/messages_$LG.class -a \
|
||||
build/obj/net/i2p/streaming/messages_$LG.class -nt $i -a \
|
||||
! -s $TMPFILE ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
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")
|
||||
# To start a new translation, copy the header from an old translation to the new .po file,
|
||||
# then ant distclean poupdate.
|
||||
find $JPATHS -name *.java > $TMPFILE
|
||||
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 --add-comments\
|
||||
--keyword=_ --keyword=_x \
|
||||
-o ${i}t
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - xgettext failed on ${i}, not updating translations"
|
||||
rm -f ${i}t
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
msgmerge -U --backup=none $i ${i}t
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgmerge failed on ${i}, not updating translations"
|
||||
rm -f ${i}t
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
rm -f ${i}t
|
||||
# so we don't do this again
|
||||
touch $i
|
||||
fi
|
||||
|
||||
if [ "$LG" != "en" ]
|
||||
then
|
||||
# only generate for non-source language
|
||||
echo "Generating ${CLASS}_$LG ResourceBundle..."
|
||||
|
||||
# convert to class files in build/obj
|
||||
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm -f $TMPFILE
|
||||
exit $RC
|
@ -109,7 +109,8 @@ public class I2PSocketException extends SocketException {
|
||||
return super.getMessage();
|
||||
|
||||
default:
|
||||
return "Failure code: " + _status;
|
||||
// Translate this one here, can't do it later
|
||||
return _("Failure code") + ": " + _status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +122,13 @@ public class I2PSocketException extends SocketException {
|
||||
String s = getMessage();
|
||||
if (s == null)
|
||||
return null;
|
||||
return _(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate
|
||||
*/
|
||||
private static String _(String s) {
|
||||
return Translate.getString(s, I2PAppContext.getGlobalContext(), BUNDLE_NAME);
|
||||
}
|
||||
|
||||
|
85
apps/ministreaming/locale/messages_en.po
Normal file
85
apps/ministreaming/locale/messages_en.po
Normal file
@ -0,0 +1,85 @@
|
||||
# I2P
|
||||
# Copyright (C) 2014 The I2P Project
|
||||
# This file is distributed under the same license as the streaming package.
|
||||
# To contribute translations, see http://www.i2p2.de/newdevelopers
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: I2P streaming\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-23 17:55+0000\n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:58
|
||||
msgid "Message timeout"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:61
|
||||
msgid "Failed delivery to local destination"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:64
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:97
|
||||
msgid "Local router failure"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:67
|
||||
msgid "Local network failure"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:70
|
||||
msgid "Session closed"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:73
|
||||
msgid "Invalid message"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:76
|
||||
msgid "Invalid message options"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:79
|
||||
msgid "Buffer overflow"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:82
|
||||
msgid "Message expired"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:85
|
||||
msgid "Local lease set invalid"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:88
|
||||
msgid "No local tunnels"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:91
|
||||
msgid "Unsupported encryption options"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:94
|
||||
msgid "Invalid destination"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:100
|
||||
msgid "Destination lease set expired"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:103
|
||||
msgid "Destination lease set not found"
|
||||
msgstr ""
|
||||
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:106
|
||||
msgid "Local destination shutdown"
|
||||
msgstr ""
|
||||
|
||||
#. Translate this one here, can't do it later
|
||||
#: ../java/src/net/i2p/client/streaming/I2PSocketException.java:113
|
||||
msgid "Failure code"
|
||||
msgstr ""
|
@ -466,6 +466,7 @@
|
||||
<ant dir="apps/susimail/" target="poupdate" />
|
||||
<ant dir="apps/desktopgui" target="poupdate" />
|
||||
<ant dir="installer/resources/locale" target="poupdate" />
|
||||
<ant dir="apps/ministreaming/" target="poupdate" />
|
||||
</target>
|
||||
|
||||
<condition property="no.bundle">
|
||||
|
@ -16,6 +16,7 @@ DIRS="\
|
||||
apps/i2ptunnel/locale \
|
||||
apps/i2ptunnel/locale-proxy \
|
||||
apps/i2psnark/locale \
|
||||
apps/ministreaming/locale \
|
||||
apps/susidns/locale \
|
||||
apps/susimail/locale \
|
||||
apps/desktopgui/locale \
|
||||
|
@ -19,6 +19,7 @@ DIRS="\
|
||||
apps/i2ptunnel/locale \
|
||||
apps/i2ptunnel/locale-proxy \
|
||||
apps/i2psnark/locale \
|
||||
apps/ministreaming/locale \
|
||||
apps/susidns/locale \
|
||||
apps/susimail/locale \
|
||||
apps/desktopgui/locale \
|
||||
|
Reference in New Issue
Block a user