Add some of my utility scripts
Add some of my utility scripts

file:b/util/msgfmt.sh (new)
--- /dev/null
+++ b/util/msgfmt.sh
@@ -1,1 +1,25 @@
+#!/bin/bash
+#
+# msgfmt.sh
+#
+# Recompiles binary MO files for all languages
+#
+# @author Christopher Han <xiphux@gmail.com>
+# @copyright Copyright (c) 2010 Christopher Han
+# @package GitPHP
+# @package util
+#
 
+LOCALEDIR="locale"
+BUNDLE="gitphp"
+
+for i in "$LOCALEDIR"/*; do
+	if [ -d "$i" ]; then
+		if [ -e "${i}/${BUNDLE}.po" ]; then
+			echo "Building ${i}..."
+			rm -f "${i}/${BUNDLE}.mo"
+			msgfmt -v -o "${i}/${BUNDLE}.mo" "${i}/${BUNDLE}.po"
+		fi
+	fi
+done
+

file:b/util/xgettext.sh (new)
--- /dev/null
+++ b/util/xgettext.sh
@@ -1,1 +1,36 @@
+#!/bin/bash
+#
+# xgettext.sh
+#
+# extracts strings from various sources
+# into one pot file
+#
+# @author Christopher Han <xiphux@gmail.com>
+# @copyright Copyright (c) 2010 Christopher Han
+# @package GitPHP
+# @package util
+#
 
+VER="`cat include/version.php | grep '^\$gitphp_version = ' | cut -d '\"' -f 2`"
+DIR="locale"
+COPYRIGHT="Christopher Han"
+EMAIL="xiphux@gmail.com"
+PKGNAME="GitPHP"
+BUNDLE="gitphp"
+FILE="gitphp.pot"
+
+# Extract from templates
+lib/smarty-gettext/tsmarty2c.php templates > smarty.c
+xgettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" --add-comments --no-location smarty.c
+rm smarty.c
+
+# Extract from include directory
+find include -iname '*.php' -type f | xgettext -ktranslate -kngettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -L PHP -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" -f -
+
+# Extract from index
+xgettext -ktranslate -kngettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -L PHP -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" index.php
+
+# File references from smarty-gettext show up as code comments,
+# convert them back to file references
+sed -e 's/^#\./#:/' -i "${DIR}/${FILE}"
+

comments