Skip to content

Commit

Permalink
A script to find literal texts to be marked for translation in qml
Browse files Browse the repository at this point in the history
in perl...

Signed-off-by: Robert C. Helling <[email protected]>
Signed-off-by: Dirk Hohndel <[email protected]>
  • Loading branch information
atdotde authored and dirkhh committed May 3, 2016
1 parent 17355c9 commit 70e3ec9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/translationmark.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env perl

# This script expects filenames on the command line and looks up text: tags in qml files and tries to wrap them with qsTr

foreach $filename (@ARGV) {
next unless $filename =~ /qml$/;
open IN, $filename;
open OUT, ">$filename.bak";
while (<IN>) {
if (/text:/ && !/qsTr/) {
if (/text:\s+(\"[^\"]*\")\s*$/) {
print OUT "$`text: qsTr($1)$'\n";
} else {
print OUT ">>>>$_";
print "$filename: $_";
}
} else {
print OUT;
}
}
close IN;
close OUT;
system "mv $filename.bak $filename";
}

0 comments on commit 70e3ec9

Please sign in to comment.