[QGIS Commit] r12658 - in trunk/qgis: scripts src/plugins/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Dec 31 11:51:37 EST 2009


Author: jef
Date: 2009-12-31 11:51:36 -0500 (Thu, 31 Dec 2009)
New Revision: 12658

Added:
   trunk/qgis/scripts/qgm2cpp.pl
Modified:
   trunk/qgis/scripts/ts2cpp.pl
   trunk/qgis/scripts/update_ts_files.sh
   trunk/qgis/src/plugins/grass/qgsgrassmapcalc.cpp
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
Log:
grass modules i18n

Added: trunk/qgis/scripts/qgm2cpp.pl
===================================================================
--- trunk/qgis/scripts/qgm2cpp.pl	                        (rev 0)
+++ trunk/qgis/scripts/qgm2cpp.pl	2009-12-31 16:51:36 UTC (rev 12658)
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use XML::Simple;
+use Data::Dumper;
+
+print <<EOF;
+/*
+ This is NOT a proper c++ source code. This file is only designed to be caught
+ by qmake and included in lupdate. It contains all translateable strings collected
+ by pylupdate4.
+*/
+
+EOF
+
+my %labels;
+my $file;
+
+sub parse {
+	foreach my $a (@_) {
+		if( ref($a) eq "ARRAY" ) {
+			foreach my $b ( @$a ) {
+				parse($b);
+			}
+		} elsif( ref($a) eq "HASH" ) {
+			foreach my $b ( keys %$a ) {
+				if( $b eq "label" ) {
+					my $label = $a->{$b};
+					die "expected string" unless ref($label) eq "";
+					print STDERR "warning[$file]: '$label' should start with a uppercase character or digit and not start or end with whitespaces"
+						if $label =~ /^\s+/ || $label =~ /\s+$/ || $label !~ /^[A-Z0-9(]/;	
+					$label =~ s/^\s+//;
+					$label =~ s/\s+$//;
+					$label =~ ucfirst $label;
+					$labels{$label} = 1;
+				} else {
+					parse($a->{$b});
+				}
+			}
+#		} elsif(ref($a) eq "") {
+#			warn "found: " . $a;
+#		} else {
+#			warn "found: " . ref($a) . " " . Dumper($a);
+		}
+	}
+}
+
+open I, "find src/plugins/grass -name '*.qgm' -o -name '*.qgc'|";
+while($file = <I>) {
+	print STDERR "$file\n";
+	chop $file;
+	parse XMLin($file, ForceArray=>1);
+	print STDERR "$file DONE\n";
+}
+close I;
+
+foreach (sort keys %labels) {
+	print "translate( \"grasslabel\", \"$_\" );\n";
+}

Modified: trunk/qgis/scripts/ts2cpp.pl
===================================================================
--- trunk/qgis/scripts/ts2cpp.pl	2009-12-31 11:52:45 UTC (rev 12657)
+++ trunk/qgis/scripts/ts2cpp.pl	2009-12-31 16:51:36 UTC (rev 12658)
@@ -1,7 +1,6 @@
 #!/usr/bin/perl
 
 use XML::Simple;
-use Data::Dumper;
 
 die "usage: $0 source.ts dest.cpp\n" unless @ARGV==2 && -f $ARGV[0];
 

Modified: trunk/qgis/scripts/update_ts_files.sh
===================================================================
--- trunk/qgis/scripts/update_ts_files.sh	2009-12-31 11:52:45 UTC (rev 12657)
+++ trunk/qgis/scripts/update_ts_files.sh	2009-12-31 16:51:36 UTC (rev 12658)
@@ -40,13 +40,14 @@
 	rm python-i18n.ts
 	cd ../../..
 done
+perl scripts/qgm2cpp.pl >src/plugins/grass/grasslabels-i18n.cpp
 echo Creating qmake project file
 qmake -project -o qgis_ts.pro -nopwd src python i18n
 echo Updating translation files
 lupdate$opts -verbose qgis_ts.pro
 echo Removing temporary python translation files
 perl -i.bak -ne 'print unless /^\s+<location.*python-i18n\.cpp.*$/;' i18n/qgis_*.ts
-rm python/python-i18n.cpp python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak
+rm python/python-i18n.cpp python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak src/plugins/grass/grasslabels-i18n.cpp
 echo Removing qmake project file
 rm qgis_ts.pro
 echo Unpacking qt_ts.tar

Modified: trunk/qgis/src/plugins/grass/qgsgrassmapcalc.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmapcalc.cpp	2009-12-31 11:52:45 UTC (rev 12657)
+++ trunk/qgis/src/plugins/grass/qgsgrassmapcalc.cpp	2009-12-31 16:51:36 UTC (rev 12658)
@@ -1314,7 +1314,7 @@
     {
       case QgsGrassMapcalcObject::Map:
       {
-        QString label = e.attribute( "label", "???" );
+        QString label = QApplication::translate( "grasslabel", e.attribute( "label", "???" ).toUtf8() );
         obj->setValue( value, label );
         break;
       }

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-12-31 11:52:45 UTC (rev 12657)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-12-31 16:51:36 UTC (rev 12658)
@@ -941,7 +941,7 @@
   qFile.close();
   QDomElement qDocElem = qDoc.documentElement();
 
-  return ( qDocElem.attribute( "label" ) );
+  return QApplication::translate( "grasslabel", qDocElem.attribute( "label" ).toUtf8() );
 }
 
 QPixmap QgsGrassModule::pixmap( QString path, int height )
@@ -2503,7 +2503,7 @@
   QString label, description;
   if ( !qdesc.attribute( "label" ).isEmpty() )
   {
-    label = qdesc.attribute( "label" );
+    label = QApplication::translate( "grasslabel", qdesc.attribute( "label" ).toUtf8() );
   }
   if ( label.isEmpty() )
   {
@@ -2511,16 +2511,14 @@
     if ( !n.isNull() )
     {
       QDomElement e = n.toElement();
-      label = e.text().trimmed();
-      label.replace( 0, 1, label.left( 1 ).toUpper() );
+      label = QApplication::translate( "grasslabel", e.text().toUtf8() );
     }
   }
   QDomNode n = gnode.namedItem( "description" );
   if ( !n.isNull() )
   {
     QDomElement e = n.toElement();
-    description = e.text().trimmed();
-    description.replace( 0, 1, description.left( 1 ).toUpper() );
+    description = QApplication::translate( "grasslabel", e.text().toUtf8() );
   }
 
   if ( !label.isEmpty() )

Modified: trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2009-12-31 11:52:45 UTC (rev 12657)
+++ trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2009-12-31 16:51:36 UTC (rev 12658)
@@ -276,7 +276,7 @@
 
       if ( e.tagName() == "section" )
       {
-        QString label = e.attribute( "label" );
+        QString label = QApplication::translate( "grasslabel", e.attribute( "label" ).toUtf8() );
         QgsDebugMsg( QString( "label = %1" ).arg( label ) );
         item->setText( 0, label );
         item->setExpanded( false );



More information about the QGIS-commit mailing list