Added the folder structure for l10n l10n
authorMark Hahnenberg <mhahnenberg@mozilla.com>
Tue, 21 Jul 2009 14:25:36 -0700
branchl10n
changeset 1113 00a7d1614f82bd19da87aba02b6e34b5d5834132
parent 1112 1d80135e9492399a46581e48f3d76547ba4462b5
child 1114 117d9501f8675c03537e08e8a473e1feaf1d57e4
push id722
push usermhahnenberg@mozilla.com
push dateThu, 30 Jul 2009 00:07:32 +0000
Added the folder structure for l10n
server/locale/README.txt
server/locale/compile-mo.sh
server/locale/en_US/LC_MESSAGES/messages.po
server/locale/extract-po.sh
server/locale/merge-enus2all.sh
server/locale/merge-po.sh
server/locale/validate-compile-mo.sh
new file mode 100644
--- /dev/null
+++ b/server/locale/README.txt
@@ -0,0 +1,23 @@
+l10n files copied from AMO/site/app/locale.
+
+We are using English Strings for gettext message ids, instead of Remora style, per L10n-drivers.
+
+Instructions:
+1) Run extract-po.sh from this directory. This will create application/messages.po
+2) merge-po.sh ../messages.po en_US/LC_MESSAGES/
+3) merge-enus2all.sh
+This will push new strings into all other locales
+
+Optional:
+4) compile-mo.sh .
+5) Restart apache
+
+New Locales:
+msginit --locale=fr -i en_US/LC_MESSAGES/messages.po
+
+Make sure you system has that locale installed...
+sudo locale-gen fr
+
+Auto compile:
+Mozilla Service Week has a cron setup on khan which automatically
+compiles and commits changes to po files.
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/server/locale/compile-mo.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# syntax:
+# compile-mo.sh locale-dir/
+
+function usage() {
+    echo "syntax:"
+    echo "compile.sh locale-dir/"
+    exit 1
+}
+
+# check if file and dir are there
+if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi
+
+for lang in `find $1 -type f -name "*.po"`; do
+    dir=`dirname $lang`
+    stem=`basename $lang .po`
+    msgfmt -f -o ${dir}/${stem}.mo $lang
+done
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/server/locale/extract-po.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+SOURCE_DIRS="config models views controllers"
+
+cd `dirname $0`/../
+
+rm messages.po
+touch messages.po
+
+for sourcedir in $SOURCE_DIRS; do \
+    find ./${sourcedir} -name "*thtml" -or -name "*.php" | xgettext \
+        --language=PHP \
+        --keyword=___ \
+        --force-po \
+        --omit-header \
+        --join-existing \
+        --add-comments \
+        --copyright-holder="Mozilla Corporation" \
+        --files-from=- # Pull from standard input (our find command) \
+done
new file mode 100644
--- /dev/null
+++ b/server/locale/merge-enus2all.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+tempfoo=`basename $0`
+TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
+
+for i in `find . -type f -name "*.po" | grep -v en_US`; do
+    msgattrib --set-fuzzy en_US/LC_MESSAGES/messages.po | msgmerge -Ns "$i" - > $TMPFILE
+    cp "$TMPFILE" "$i"
+done
+rm "$TMPFILE"
new file mode 100644
--- /dev/null
+++ b/server/locale/merge-po.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# syntax:
+# merge-po.sh extracted.pot destination-dir/
+
+function usage() {
+    echo "syntax:"
+    echo "merge-po.sh extracted.pot destination-dir/"
+    exit 1
+}
+
+tempfoo=`basename $0`
+TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
+
+# check if file and dir are there
+if [[ ($# -ne 2) || (! -f "$1") || (! -d "$2") ]]; then usage; fi
+
+for lang in `find $2 -type f -name "*.po"`; do
+    msgmerge --update $lang $1 > $TMPFILE
+    cp "$TMPFILE" "$lang"
+done
+rm "$TMPFILE"
new file mode 100644
--- /dev/null
+++ b/server/locale/validate-compile-mo.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# syntax:
+# compile-mo.sh locale-dir/
+
+function usage() {
+    echo "syntax:"
+    echo "compile.sh locale-dir/"
+    exit 1
+}
+
+# check if file and dir are there
+if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi
+
+for lang in `find $1 -type f -name "*.po"`; do
+    dir=`dirname $lang`
+    stem=`basename $lang .po`
+    msgfmt -c -C -v -o ${dir}/${stem}.mo $lang
+done