From 827a92ef2f3bb743f8d9ca332e4628ed66be2600 Mon Sep 17 00:00:00 2001
From: walking <walking@mail.i2p>
Date: Thu, 5 Nov 2009 13:35:33 +0000
Subject: [PATCH] bundle-messag windows hack

---
 apps/routerconsole/java/bmsg.sh             | 84 +++++++++++++++++++++
 apps/routerconsole/java/bundle-messages.bat |  6 ++
 2 files changed, 90 insertions(+)
 create mode 100644 apps/routerconsole/java/bmsg.sh
 create mode 100644 apps/routerconsole/java/bundle-messages.bat

diff --git a/apps/routerconsole/java/bmsg.sh b/apps/routerconsole/java/bmsg.sh
new file mode 100644
index 0000000000..e66bcc317a
--- /dev/null
+++ b/apps/routerconsole/java/bmsg.sh
@@ -0,0 +1,84 @@
+#
+# 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
+
+
+CLASS=net.i2p.router.web.messages
+TMPFILE=build/javafiles.txt
+export TZ=UTC
+
+for i in ../locale/messages_*.po
+do
+	# get language
+	LG=${i#../locale/messages_}
+	LG=${LG%.po}
+
+	# make list of java files newer than the .po file
+	find src ../jsp/WEB-INF strings -name *.java -newer $i > $TMPFILE
+	if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
+	     build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
+	     ! -s $TMPFILE ]
+	then
+		continue
+	fi
+
+	echo "Generating ${CLASS}_$LG ResourceBundle..."
+
+	# 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 src ../jsp/WEB-INF strings -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
+	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
diff --git a/apps/routerconsole/java/bundle-messages.bat b/apps/routerconsole/java/bundle-messages.bat
new file mode 100644
index 0000000000..6bafcdd554
--- /dev/null
+++ b/apps/routerconsole/java/bundle-messages.bat
@@ -0,0 +1,6 @@
+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 
+@echo off
+set Callfrom=%cd%
+sh --login %cd%\bmsg.sh
\ No newline at end of file
-- 
GitLab