[med-svn] r624 - trunk/community/website/locale

hanska-guest at alioth.debian.org hanska-guest at alioth.debian.org
Fri Oct 5 19:31:51 UTC 2007


Author: hanska-guest
Date: 2007-10-05 19:31:51 +0000 (Fri, 05 Oct 2007)
New Revision: 624

Added:
   trunk/community/website/locale/add-locale
Log:
First script to automatically add a locale.
IT HAS NOT BEEN TESTED YET. USE IT AT YOUR OWN RISK.


Added: trunk/community/website/locale/add-locale
===================================================================
--- trunk/community/website/locale/add-locale	                        (rev 0)
+++ trunk/community/website/locale/add-locale	2007-10-05 19:31:51 UTC (rev 624)
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+set -x
+__ver=0.1
+__shell=$(getent passwd $(id -un) | cut -f7- -d:)
+
+[ -z "$__shell" ] && __shell=/bin/sh
+
+usage() {
+	echo  "$0 ver. $__ver\n\n
+Usage: $0 [ options ] locale\n\n
+Command\t\t\tAction\n
+--no-option
+-n\t\t\t\tDon't commit changes after
+\t\t\t\tclosing the editor"
+}
+
+if [ -z "$(which msgfmt)" ]
+then
+	echo "[E]: You need to install the gettext package."
+	exit 1
+else if [ -z "$(which svn)" ]
+then
+	echo "[E]: You need to install the subversion package."
+	exit 1
+fi
+
+[ "$#" -eq "0" ] && usage
+
+while [ "$#" -ge "1" ]
+do
+	case $1 in
+		--no-commit|-n)
+			commit=0;
+			if [ -n "$2" ]
+			then
+				locale=$2
+			else
+				echo "[E]: Please, specify a locale to add.";
+			fi
+			break;;
+		*)
+			locale=$1;
+			break;;
+	esac
+	shift;
+done
+
+mkdir -pv $locale/LC_MESSAGES/
+cp -vrf messages.pot $locale/LC_MESSAGES/message.po
+
+echo "$(basename $0):
+
+Now launching an interactive shell in your work directory. Edit your files.
+When you are done, exit the shell, and the translated .po file will automatically
+be compiled and committed.
+
+If you wish to abort the process, exit the shell such that it returns an exit
+code of "999". This is typically done by exiting the shell with the command
+'exit 999'."
+
+sleep 10s
+
+$__shell -c "sensible-editor $locale/LC_MESSAGES/messages.po" && __exit=0 || __exit="$?"
+if [ "$__exit" -eq "999" ]
+then
+	echo "Shell exited with code 999, aborting."
+	exit 2
+else if [ "$__exit" -eq "0" ]
+then
+	( cd $locale/LC_MESSAGES/messages.po && msgfmt messages.po )
+	svn add $locale
+	if [ "x$commit" == "x1" ]
+	then
+		svn commit -m "Adding new locale: $locale (auto-generated by add-locale)"
+	else
+		echo "[W]: The changes you have made are not committed to SVN."
+		echo "[+]: Please review your messages.po, recompile it if needed,"
+		echo "[+]: and 'svn commit' your $locale/ directory (it is already"
+		echo "[+]: added to the SVN repository)."
+	fi
+	exit 0
+else
+	echo "Shell exited with a code different from 999 or 0, error detected."
+	exit 3
+fi
+
+exit 0


Property changes on: trunk/community/website/locale/add-locale
___________________________________________________________________
Name: svn:executable
   + *




More information about the debian-med-commit mailing list