mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
grass modules i18n
git-svn-id: http://svn.osgeo.org/qgis/trunk@12658 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
b07d7d70d5
commit
57e37f8d66
58
scripts/qgm2cpp.pl
Normal file
58
scripts/qgm2cpp.pl
Normal file
@ -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";
|
||||
}
|
@ -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];
|
||||
|
||||
|
@ -40,13 +40,14 @@ for i in python/plugins/*/CMakeLists.txt; do
|
||||
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
|
||||
|
@ -1314,7 +1314,7 @@ void QgsGrassMapcalc::load()
|
||||
{
|
||||
case QgsGrassMapcalcObject::Map:
|
||||
{
|
||||
QString label = e.attribute( "label", "???" );
|
||||
QString label = QApplication::translate( "grasslabel", e.attribute( "label", "???" ).toUtf8() );
|
||||
obj->setValue( value, label );
|
||||
break;
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ QString QgsGrassModule::label( QString path )
|
||||
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 @@ QgsGrassModuleItem::QgsGrassModuleItem( QgsGrassModule *module, QString key,
|
||||
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 @@ QgsGrassModuleItem::QgsGrassModuleItem( QgsGrassModule *module, QString key,
|
||||
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() )
|
||||
|
@ -276,7 +276,7 @@ void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element )
|
||||
|
||||
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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user