summaryrefslogtreecommitdiffstats
path: root/scripts/translationmark.pl
blob: b206ed12fc38cfcec1d67481d5acf3a97b7d879e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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";
}