Skip to content

Commit 57e37f8

Browse files
author
jef
committed
grass modules i18n
git-svn-id: http://svn.osgeo.org/qgis/trunk@12658 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b07d7d7 commit 57e37f8

File tree

6 files changed

+66
-10
lines changed

6 files changed

+66
-10
lines changed

scripts/qgm2cpp.pl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/perl
2+
3+
use XML::Simple;
4+
use Data::Dumper;
5+
6+
print <<EOF;
7+
/*
8+
This is NOT a proper c++ source code. This file is only designed to be caught
9+
by qmake and included in lupdate. It contains all translateable strings collected
10+
by pylupdate4.
11+
*/
12+
13+
EOF
14+
15+
my %labels;
16+
my $file;
17+
18+
sub parse {
19+
foreach my $a (@_) {
20+
if( ref($a) eq "ARRAY" ) {
21+
foreach my $b ( @$a ) {
22+
parse($b);
23+
}
24+
} elsif( ref($a) eq "HASH" ) {
25+
foreach my $b ( keys %$a ) {
26+
if( $b eq "label" ) {
27+
my $label = $a->{$b};
28+
die "expected string" unless ref($label) eq "";
29+
print STDERR "warning[$file]: '$label' should start with a uppercase character or digit and not start or end with whitespaces"
30+
if $label =~ /^\s+/ || $label =~ /\s+$/ || $label !~ /^[A-Z0-9(]/;
31+
$label =~ s/^\s+//;
32+
$label =~ s/\s+$//;
33+
$label =~ ucfirst $label;
34+
$labels{$label} = 1;
35+
} else {
36+
parse($a->{$b});
37+
}
38+
}
39+
# } elsif(ref($a) eq "") {
40+
# warn "found: " . $a;
41+
# } else {
42+
# warn "found: " . ref($a) . " " . Dumper($a);
43+
}
44+
}
45+
}
46+
47+
open I, "find src/plugins/grass -name '*.qgm' -o -name '*.qgc'|";
48+
while($file = <I>) {
49+
print STDERR "$file\n";
50+
chop $file;
51+
parse XMLin($file, ForceArray=>1);
52+
print STDERR "$file DONE\n";
53+
}
54+
close I;
55+
56+
foreach (sort keys %labels) {
57+
print "translate( \"grasslabel\", \"$_\" );\n";
58+
}

scripts/ts2cpp.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/perl
22

33
use XML::Simple;
4-
use Data::Dumper;
54

65
die "usage: $0 source.ts dest.cpp\n" unless @ARGV==2 && -f $ARGV[0];
76

scripts/update_ts_files.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ for i in python/plugins/*/CMakeLists.txt; do
4040
rm python-i18n.ts
4141
cd ../../..
4242
done
43+
perl scripts/qgm2cpp.pl >src/plugins/grass/grasslabels-i18n.cpp
4344
echo Creating qmake project file
4445
qmake -project -o qgis_ts.pro -nopwd src python i18n
4546
echo Updating translation files
4647
lupdate$opts -verbose qgis_ts.pro
4748
echo Removing temporary python translation files
4849
perl -i.bak -ne 'print unless /^\s+<location.*python-i18n\.cpp.*$/;' i18n/qgis_*.ts
49-
rm python/python-i18n.cpp python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak
50+
rm python/python-i18n.cpp python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak src/plugins/grass/grasslabels-i18n.cpp
5051
echo Removing qmake project file
5152
rm qgis_ts.pro
5253
echo Unpacking qt_ts.tar

src/plugins/grass/qgsgrassmapcalc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ void QgsGrassMapcalc::load()
13141314
{
13151315
case QgsGrassMapcalcObject::Map:
13161316
{
1317-
QString label = e.attribute( "label", "???" );
1317+
QString label = QApplication::translate( "grasslabel", e.attribute( "label", "???" ).toUtf8() );
13181318
obj->setValue( value, label );
13191319
break;
13201320
}

src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ QString QgsGrassModule::label( QString path )
941941
qFile.close();
942942
QDomElement qDocElem = qDoc.documentElement();
943943

944-
return ( qDocElem.attribute( "label" ) );
944+
return QApplication::translate( "grasslabel", qDocElem.attribute( "label" ).toUtf8() );
945945
}
946946

947947
QPixmap QgsGrassModule::pixmap( QString path, int height )
@@ -2503,24 +2503,22 @@ QgsGrassModuleItem::QgsGrassModuleItem( QgsGrassModule *module, QString key,
25032503
QString label, description;
25042504
if ( !qdesc.attribute( "label" ).isEmpty() )
25052505
{
2506-
label = qdesc.attribute( "label" );
2506+
label = QApplication::translate( "grasslabel", qdesc.attribute( "label" ).toUtf8() );
25072507
}
25082508
if ( label.isEmpty() )
25092509
{
25102510
QDomNode n = gnode.namedItem( "label" );
25112511
if ( !n.isNull() )
25122512
{
25132513
QDomElement e = n.toElement();
2514-
label = e.text().trimmed();
2515-
label.replace( 0, 1, label.left( 1 ).toUpper() );
2514+
label = QApplication::translate( "grasslabel", e.text().toUtf8() );
25162515
}
25172516
}
25182517
QDomNode n = gnode.namedItem( "description" );
25192518
if ( !n.isNull() )
25202519
{
25212520
QDomElement e = n.toElement();
2522-
description = e.text().trimmed();
2523-
description.replace( 0, 1, description.left( 1 ).toUpper() );
2521+
description = QApplication::translate( "grasslabel", e.text().toUtf8() );
25242522
}
25252523

25262524
if ( !label.isEmpty() )

src/plugins/grass/qgsgrasstools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element )
276276

277277
if ( e.tagName() == "section" )
278278
{
279-
QString label = e.attribute( "label" );
279+
QString label = QApplication::translate( "grasslabel", e.attribute( "label" ).toUtf8() );
280280
QgsDebugMsg( QString( "label = %1" ).arg( label ) );
281281
item->setText( 0, label );
282282
item->setExpanded( false );

0 commit comments

Comments
 (0)