Hi,

On 18 Oct 2015, at 16:53, Dirk Hohndel <[email protected]> wrote:


That doesn't appear to be an option when using the free version of Transifex.
At least I don't have these menus.


From fe21be5642b65cf74f5c6e591b7306725ec7e8a3 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sun, 18 Oct 2015 17:16:46 +0200
Subject: [PATCH] A perl script to check format strings in translations

This script can be called on translations files, e.g.

> scripts/checktranslation.pl translations/*ts

and will report if the number of % signs in source and translation
differ.

Signed-off-by: Robert C. Helling <[email protected]>
---
 scripts/checktranslation.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 scripts/checktranslation.pl

diff --git a/scripts/checktranslation.pl b/scripts/checktranslation.pl
new file mode 100755
index 0000000..63d0f09
--- /dev/null
+++ b/scripts/checktranslation.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl -CS
+
+use strict;
+use utf8;
+use XML::TreeBuilder;
+
+foreach my $file_name (@ARGV) {
+       my $tree = XML::TreeBuilder->new({'NoExpand' => 0, 'ErrorContext' => 
0});
+       $tree->parse_file($file_name, ProtocolEncoding => 'UTF-8');
+       foreach my $string ($tree->find_by_tag_name('message')) {
+               my $source = $string->find_by_tag_name('source')->as_text;
+               my $translation = 
$string->find_by_tag_name('translation')->as_text;
+               next unless $translation =~ /\S/;
+               my @source_args = ($source =~ /\%([^\s\-\(\)])/g);
+               my @translation_args = ($translation =~ /\%([^\s\-\(\)])/g);
+               if (scalar(@source_args) != scalar(@translation_args)) {
+                       print "$file_name:\n$source\n->\n$translation\n\n";
+               }
+       }
+}
+
+
-- 
1.9.5 (Apple Git-50.3)

I hacked a perl script to be run on the translation files to detect this kind of problem. There are a number of false positives but it seems to me, this finds a number of other possible offenders.

Best
Robert

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to