From 930dd0f1caeefb74a6b9f18fd89080baa3c97442 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 3 May 2016 18:14:41 +0200 Subject: [PATCH 1/2] A script to find literal texts to be marked for translation in qml To: subsurface@subsurface-divelog.org in perl... Signed-off-by: Robert C. Helling --- scripts/translationmark.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/translationmark.pl diff --git a/scripts/translationmark.pl b/scripts/translationmark.pl new file mode 100755 index 0000000..b206ed1 --- /dev/null +++ b/scripts/translationmark.pl @@ -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 () { + 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"; +} -- 2.6.4 (Apple Git-63)