[Fusionforge-commits] r7896 - trunk/tools

Christian Bayle cbayle at libremir.placard.fr.eu.org
Sun Jun 21 23:08:22 CEST 2009


Author: cbayle
Date: 2009-06-21 23:08:22 +0200 (Sun, 21 Jun 2009)
New Revision: 7896

Modified:
   trunk/tools/tab2gettext.sh
Log:
Hardening the script, need to be run 5 times


Modified: trunk/tools/tab2gettext.sh
===================================================================
--- trunk/tools/tab2gettext.sh	2009-06-21 18:49:08 UTC (rev 7895)
+++ trunk/tools/tab2gettext.sh	2009-06-21 21:08:22 UTC (rev 7896)
@@ -3,6 +3,7 @@
 # This file is used to convert $GLOBALS['Language']->getText('str1','str2') to gettext("English String from tab(str1,str2)")
 # Copyright Christian Bayle <bayle at debian.org> 2009
 # Licenced as GPL v2 or next or Affero GPL to your courtesy
+# Thanks to PK for perl regexp help
 # 
 # Interesting part is to point non translatable strings, that should maybe be modified  before operation
 # not sure it is useable as is as in only replace strings for english.
@@ -25,7 +26,8 @@
 	#echo "Converting in $3"
 	echo "+++ $var1 ==> $var2 +++"
 	#perl -pi -e "s/$var1/$var2/g" $3
-	perl -pi -e "s{$var1}{$var2}go" $3
+	#perl -pi -e "s{$var1}{$var2}go" $3
+	perl -pi -e "s{$var1}{$var2}sg" $3
 }
 
 decode()
@@ -44,7 +46,8 @@
 				*\$*)
 					strns=`echo "$strn" | sed 's/\$./%s/g'` 
 					newstrn="gettext(\"$strns\","
-					grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS.*('$1'.*'$2',\).*/\1/"| sort -u | while read oldstrn
+					#grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS.*('$1'.*'$2',\).*/\1/"| sort -u | while read oldstrn
+					grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS\['Language'\].[^(]*('$1'.*'$2',\).*/\1/"| sort -u | while read oldstrn
 					do
 						#echo "== \$$oldstrn ==> $newstrn =="
 						substitute "$oldstrn" "$newstrn" "$3"
@@ -52,7 +55,8 @@
 					;;
 				*)
 					newstrn="gettext(\"$strn\")"
-					grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS.*('$1'.*'$2')\).*/\1/"| sort -u | while read oldstrn
+					#grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS.*('$1'.*'$2')\).*/\1/"| sort -u | while read oldstrn
+					grep "'$1'.*'$2'" $file | sed "s/.*\(GLOBALS\['Language'\].[^(]*('$1'.*'$2')\).*/\1/"| sort -u | while read oldstrn
 					do
 						#echo "== \$$oldstrn ==> $newstrn =="
 						substitute "$oldstrn" "$newstrn" "$3"
@@ -91,9 +95,10 @@
 	#grep "getText(" $file | sed "s/.*getText.[^']*'\(.[^']*\)'.[^']*'\(.[^']*\)'.*/\1	\2/g" | while read key1 key2
 	#grep "getText(" $file | sed "s/.*getText('\(.[^']*\)'.[^']*'\(.[^']*\)'.*/\1	\2/g" | while read key1 key2
 	#
-	perl -pi -e "s{\\QLanguage->getText\\E}{GLOBALS['Language']->getText}go" $file
+	perl -pi -e "s{\\QLanguage->getText\\E}{GLOBALS['Language']->getText}sg" $file
 	#
-	grep "getText('.[^']*'.[^']*'.[^']*'.*" $file | sed "s/.*getText('\(.[^']*\)'.[^']*'\(.[^']*\)'.*/\1	\2/g" | while read key1 key2
+	#grep "getText('.[^']*'.[^']*'.[^']*'.*" $file | sed "s/.*getText('\(.[^']*\)'.[^']*'\(.[^']*\)'.*/\1	\2/g" | while read key1 key2
+	grep "GLOBALS\['Language'\]->getText('.[^']*'.[^']*'.[^']*'.*" $file | sed "s/.*GLOBALS\['Language'\]->getText('\(.[^']*\)'.[^']*'\(.[^']*\)'.*/\1	\2/g" | while read key1 key2
 	do
 		if [ "$found" = "0" ] 
 		then 




More information about the Fusionforge-commits mailing list