forked from I2P_Developers/i2p.i2p
translation support
This commit is contained in:
17
apps/i2ptunnel/java/bmsg.sh
Normal file
17
apps/i2ptunnel/java/bmsg.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
# Update messages_xx.po and messages_xx.class files,
|
||||||
|
# from both java and jsp sources.
|
||||||
|
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
|
||||||
|
# zzz - public domain
|
||||||
|
#
|
||||||
|
|
||||||
|
## launching sh.exe with -login parameter will open a shell with the current path always pointing to \bin\
|
||||||
|
## need to cd into our orignal path - where we call sh.exe from.
|
||||||
|
|
||||||
|
cd $CALLFROM
|
||||||
|
## echo $PWD
|
||||||
|
|
||||||
|
## except this everything is the same with bundle-message.sh
|
||||||
|
## walking - public domain :-D
|
||||||
|
|
||||||
|
source bundle-messages.sh $PARAS
|
@ -42,12 +42,49 @@
|
|||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
<ant target="war" />
|
<ant target="war" />
|
||||||
|
<ant target="bundle" />
|
||||||
|
<!-- jar again to get the latest messages_*.class files -->
|
||||||
|
<jar destfile="./build/i2ptunnel.jar" basedir="./build/obj" includes="**/*.class" update="true" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="bundle" depends="compile, precompilejsp">
|
||||||
|
<!-- 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="false" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
</exec>
|
||||||
|
<exec executable="sh" osfamily="mac" failifexecutionfails="false" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
</exec>
|
||||||
|
<exec executable="cmd" osfamily="windows" failifexecutionfails="false" >
|
||||||
|
<arg value="/c" />
|
||||||
|
<arg value="bundle-messages.bat" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="poupdate" depends="compile, precompilejsp">
|
||||||
|
<!-- Update the messages_*.po files. -->
|
||||||
|
<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">
|
||||||
<war destfile="build/i2ptunnel.war" webxml="../jsp/web-out.xml"
|
<war destfile="build/i2ptunnel.war" webxml="../jsp/web-out.xml"
|
||||||
basedir="../jsp/" excludes="web.xml, **/*.java, *.jsp">
|
basedir="../jsp/" excludes="web.xml, **/*.java, *.jsp">
|
||||||
</war>
|
</war>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="precompilejsp" unless="precompilejsp.uptodate">
|
<target name="precompilejsp" unless="precompilejsp.uptodate">
|
||||||
<delete dir="../jsp/WEB-INF/" />
|
<delete dir="../jsp/WEB-INF/" />
|
||||||
<delete file="../jsp/web-fragment.xml" />
|
<delete file="../jsp/web-fragment.xml" />
|
||||||
@ -113,11 +150,7 @@
|
|||||||
<delete file="../jsp/web-out.xml" />
|
<delete file="../jsp/web-out.xml" />
|
||||||
</target>
|
</target>
|
||||||
<target name="cleandep" depends="clean">
|
<target name="cleandep" depends="clean">
|
||||||
<!-- ministreaming will clean core -->
|
|
||||||
<ant dir="../../ministreaming/java/" target="distclean" />
|
|
||||||
</target>
|
</target>
|
||||||
<target name="distclean" depends="clean">
|
<target name="distclean" depends="clean">
|
||||||
<!-- ministreaming will clean core -->
|
|
||||||
<ant dir="../../ministreaming/java/" target="distclean" />
|
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
26
apps/i2ptunnel/java/bundle-messages.bat
Normal file
26
apps/i2ptunnel/java/bundle-messages.bat
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@echo off
|
||||||
|
set Callfrom=%cd%
|
||||||
|
set Paras=%1
|
||||||
|
|
||||||
|
rem before calling make sure you have msys and mingw 's "bin" path
|
||||||
|
rem in your current searching path
|
||||||
|
rem type "set path" to check
|
||||||
|
if not exist ..\locale\*.only goto updateALL
|
||||||
|
|
||||||
|
rem put a messages_xx.only(eg messages_zh.only) into locale folder
|
||||||
|
rem this script will only touch the po file(eg zh) you specified, leaving other po files untact.
|
||||||
|
|
||||||
|
for %%i in (..\locale\*.only) do set PO=%%~ni
|
||||||
|
echo [Notice] Yu choose to Ony update the choosen file: %PO%.po
|
||||||
|
for %%i in (..\locale\*.po) do if not %%~ni==%PO% ren %%i %%~ni.po-
|
||||||
|
|
||||||
|
call sh --login %cd%\bmsg.sh
|
||||||
|
|
||||||
|
for %%i in (..\locale\*.po-) do if not %%~ni==%PO% ren %%i %%~ni.po
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:updateALL
|
||||||
|
call sh --login %cd%\bmsg.sh
|
||||||
|
|
||||||
|
:end
|
||||||
|
echo End of Message Bundling
|
88
apps/i2ptunnel/java/bundle-messages.sh
Executable file
88
apps/i2ptunnel/java/bundle-messages.sh
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#
|
||||||
|
# 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.i2ptunnel.web.messages
|
||||||
|
TMPFILE=build/javafiles.txt
|
||||||
|
export TZ=UTC
|
||||||
|
|
||||||
|
if [ "$1" = "-p" ]
|
||||||
|
then
|
||||||
|
POUPDATE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add ../java/ so the refs will work in the po file
|
||||||
|
JPATHS="../java/src ../jsp/WEB-INF"
|
||||||
|
for i in ../locale/messages_*.po
|
||||||
|
do
|
||||||
|
# get language
|
||||||
|
LG=${i#../locale/messages_}
|
||||||
|
LG=${LG%.po}
|
||||||
|
|
||||||
|
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/i2ptunnel/messages_$LG.class -a \
|
||||||
|
build/obj/net/i2p/i2ptunnel/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")
|
||||||
|
# intl._("foo")
|
||||||
|
# intl.title("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 \
|
||||||
|
-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
|
||||||
|
|
||||||
|
echo "Generating ${CLASS}_$LG ResourceBundle..."
|
||||||
|
|
||||||
|
# convert to class files in build/obj
|
||||||
|
msgfmt --java -r $CLASS -l $LG -d build/obj $i
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo 'Warning - msgfmt failed, not updating translations'
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm -f $TMPFILE
|
||||||
|
# todo: return failure
|
||||||
|
exit 0
|
37
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/Messages.java
Normal file
37
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/Messages.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package net.i2p.i2ptunnel.web;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.util.Translate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate strings for this package.
|
||||||
|
*/
|
||||||
|
public class Messages {
|
||||||
|
private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.messages";
|
||||||
|
private final I2PAppContext _context;
|
||||||
|
|
||||||
|
public Messages() {
|
||||||
|
_context = I2PAppContext.getGlobalContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** lang in routerconsole.lang property, else current locale */
|
||||||
|
public String _(String key) {
|
||||||
|
return Translate.getString(key, _context, BUNDLE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* translate a string with a parameter
|
||||||
|
* This is a lot more expensive than getString(s, ctx), so use sparingly.
|
||||||
|
*
|
||||||
|
* @param s string to be translated containing {0}
|
||||||
|
* The {0} will be replaced by the parameter.
|
||||||
|
* Single quotes must be doubled, i.e. ' -> '' in the string.
|
||||||
|
* @param o parameter, not translated.
|
||||||
|
* To tranlslate parameter also, use _("foo {0} bar", _("baz"))
|
||||||
|
* Do not double the single quotes in the parameter.
|
||||||
|
* Use autoboxing to call with ints, longs, floats, etc.
|
||||||
|
*/
|
||||||
|
public String _(String s, Object o) {
|
||||||
|
return Translate.getString(s, o, _context, BUNDLE_NAME);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"%><?xml version="1.0" encoding="UTF-8"?>
|
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"%><?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<jsp:useBean class="net.i2p.i2ptunnel.web.EditBean" id="editBean" scope="request" />
|
<jsp:useBean class="net.i2p.i2ptunnel.web.EditBean" id="editBean" scope="request" />
|
||||||
|
<jsp:useBean class="net.i2p.i2ptunnel.web.Messages" id="intl" scope="request" />
|
||||||
<% String tun = request.getParameter("tunnel");
|
<% String tun = request.getParameter("tunnel");
|
||||||
int curTunnel = -1;
|
int curTunnel = -1;
|
||||||
if (tun != null) {
|
if (tun != null) {
|
||||||
@ -13,7 +14,7 @@
|
|||||||
%>
|
%>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>I2P Tunnel Manager - Edit</title>
|
<title><%=intl._("I2P Tunnel Manager - Edit Client Tunnel")%></title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"%><?xml version="1.0" encoding="UTF-8"?>
|
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"%><?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<jsp:useBean class="net.i2p.i2ptunnel.web.EditBean" id="editBean" scope="request" />
|
<jsp:useBean class="net.i2p.i2ptunnel.web.EditBean" id="editBean" scope="request" />
|
||||||
|
<jsp:useBean class="net.i2p.i2ptunnel.web.Messages" id="intl" scope="request" />
|
||||||
<% String tun = request.getParameter("tunnel");
|
<% String tun = request.getParameter("tunnel");
|
||||||
int curTunnel = -1;
|
int curTunnel = -1;
|
||||||
if (tun != null) {
|
if (tun != null) {
|
||||||
@ -13,7 +14,7 @@
|
|||||||
%>
|
%>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>I2P Tunnel Manager - Edit</title>
|
<title><%=intl._("I2P Tunnel Manager - Edit Server Tunnel")%></title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||||
|
|
||||||
|
@ -8,9 +8,10 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<jsp:useBean class="net.i2p.i2ptunnel.web.IndexBean" id="indexBean" scope="request" />
|
<jsp:useBean class="net.i2p.i2ptunnel.web.IndexBean" id="indexBean" scope="request" />
|
||||||
<jsp:setProperty name="indexBean" property="*" />
|
<jsp:setProperty name="indexBean" property="*" />
|
||||||
|
<jsp:useBean class="net.i2p.i2ptunnel.web.Messages" id="intl" scope="request" />
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>I2P Tunnel Manager - List</title>
|
<title><%=intl._("I2P Tunnel Manager - List")%></title>
|
||||||
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||||
|
30
apps/i2ptunnel/locale/messages_de.po
Normal file
30
apps/i2ptunnel/locale/messages_de.po
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# I2P
|
||||||
|
# Copyright (C) 2009 The I2P Project
|
||||||
|
# This file is distributed under the same license as the i2ptunnel package.
|
||||||
|
# To contribute translations, see http://www.i2p2.de/newdevelopers
|
||||||
|
# foo <foo@bar>, 2009.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: I2P i2ptunnel\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2009-12-10 00:50+0000\n"
|
||||||
|
"PO-Revision-Date: 2009-10-19 12:50+0000\n"
|
||||||
|
"Last-Translator: foo <foo@bar>\n"
|
||||||
|
"Language-Team: foo <foo@bar>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Poedit-Language: German\n"
|
||||||
|
|
||||||
|
#: ../jsp/WEB-INF/classes/net/i2p/i2ptunnel/jsp/editClient_jsp.java:73
|
||||||
|
msgid "I2P Tunnel Manager - Edit Client Tunnel"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../jsp/WEB-INF/classes/net/i2p/i2ptunnel/jsp/editServer_jsp.java:73
|
||||||
|
msgid "I2P Tunnel Manager - Edit Server Tunnel"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../jsp/WEB-INF/classes/net/i2p/i2ptunnel/jsp/index_jsp.java:71
|
||||||
|
msgid "I2P Tunnel Manager - List"
|
||||||
|
msgstr ""
|
@ -142,6 +142,7 @@
|
|||||||
<target name="poupdate">
|
<target name="poupdate">
|
||||||
<ant dir="apps/routerconsole/java/" target="poupdate" />
|
<ant dir="apps/routerconsole/java/" target="poupdate" />
|
||||||
<ant dir="apps/i2psnark/java/" target="poupdate" />
|
<ant dir="apps/i2psnark/java/" target="poupdate" />
|
||||||
|
<ant dir="apps/i2ptunnel/java/" target="poupdate" />
|
||||||
</target>
|
</target>
|
||||||
<target name="javadoc">
|
<target name="javadoc">
|
||||||
<mkdir dir="./build" />
|
<mkdir dir="./build" />
|
||||||
|
Reference in New Issue
Block a user