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

hanska-guest at alioth.debian.org hanska-guest at alioth.debian.org
Sat Oct 6 18:15:55 UTC 2007


Author: hanska-guest
Date: 2007-10-06 18:15:55 +0000 (Sat, 06 Oct 2007)
New Revision: 667

Modified:
   trunk/community/website/locale/add-locale
Log:
Now the script works! :)

First test commit in a few moments...


Modified: trunk/community/website/locale/add-locale
===================================================================
--- trunk/community/website/locale/add-locale	2007-10-06 17:19:08 UTC (rev 666)
+++ trunk/community/website/locale/add-locale	2007-10-06 18:15:55 UTC (rev 667)
@@ -1,9 +1,11 @@
 #!/bin/sh
 
-#set -x
 __ver=0.1
 __shell=$(getent passwd $(id -un) | cut -f7- -d:)
 
+# Set this to the website root directory
+__base=.. 
+
 [ -z "$__shell" ] && __shell=/bin/sh
 
 usage() {
@@ -22,6 +24,10 @@
 	exit 1
 }
 
+start() {
+	$__shell && __exit=0 || __exit="$?"
+}
+
 [ -z "$(which msgfmt)" ] && need gettext
 [ -z "$(which svn)" ] && need subversion
 [ "$#" -eq "0" ] && usage
@@ -39,6 +45,7 @@
 			fi
 			break;;
 		*)
+			commit=1;
 			locale=$1;
 			break;;
 	esac
@@ -48,6 +55,8 @@
 mkdir -pv $locale/LC_MESSAGES/
 cp -vrf messages.pot $locale/LC_MESSAGES/messages.po
 
+sed -i "s/YEAR-MO-DA HO:MI+ZONE/`date +"%Y-%m-%d %H:%M%z"`/" $locale/LC_MESSAGES/messages.po
+
 echo "$(basename $0):
 
 Now launching an interactive shell in your work directory. Edit your files.
@@ -55,32 +64,46 @@
 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'."
+code of "222". This is typically done by exiting the shell with the command
+'exit 222'."
 
-$__shell -c "sleep 10s; sensible-editor $locale/LC_MESSAGES/messages.po" && __exit=0 || __exit="$?"
+__olddir=$(pwd)
+cd $locale/LC_MESSAGES/
 
-if [ "$__exit" -eq "999" ]
+$__shell && __code=0 || __code="$?"
+
+echo "exit: $__code";
+
+if [ "$__code" = "222" ]
 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" ]
+	echo "Shell exited with code 222, aborting."
+	exit 1
+else
+	if [ "$__code" = "0" ]
 	then
-		svn commit -m "Adding new locale: $locale (auto-generated by add-locale)"
+		msgfmt messages.po
+		
+		cd $__olddir
+		svn add $locale
+		
+		[ -z "$(grep $locale $__base/inc/locales.txt)" ] && echo -e "\n$locale\t$locale\n" >> $__base/inc/locales.txt
+		
+		if [ "$commit" = "1" ]
+		then
+			cd $__base
+			svn commit -m "Adding new locale: $locale (auto-generated by add-locale)"
+		else
+			echo ""
+			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)."
+			echo ""
+		fi
 	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)."
+		echo "Shell exited with a code different from 999 or 0, error detected."
+		exit 1
 	fi
-	exit 0
-else
-	echo "Shell exited with a code different from 999 or 0, error detected."
-	exit 3
 fi
 
 exit 0




More information about the debian-med-commit mailing list