Skip to content

Commit 9e45223

Browse files
committed
reset English translations on update
1 parent 9ad01cf commit 9e45223

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

scripts/ts-clear.pl

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env perl
2+
###########################################################################
3+
# ts-clear.pl
4+
# ---------------------
5+
# begin : October 2018
6+
# copyright : (C) 2018 by Juergen E. Fischer
7+
# email : jef at norbit dot de
8+
###########################################################################
9+
# #
10+
# This program is free software; you can redistribute it and/or modify #
11+
# it under the terms of the GNU General Public License as published by #
12+
# the Free Software Foundation; either version 2 of the License, or #
13+
# (at your option) any later version. #
14+
# #
15+
###########################################################################
16+
17+
use strict;
18+
use warnings;
19+
use Carp qw/croak/;
20+
use XML::Simple;
21+
use Data::Dumper;
22+
23+
$SIG{__WARN__} = sub { croak @_; };
24+
25+
my $xml = XMLin("i18n/qgis_en.ts", ForceArray=>1);
26+
27+
die "context expected" unless exists $xml->{context};
28+
29+
foreach my $context ( @{ $xml->{context} } ) {
30+
foreach my $message ( @{ $context->{message} } ) {
31+
if(exists $message->{numerus} && $message->{numerus} eq "yes") {
32+
for my $nf ( @{ $message->{translation}->[0]->{numerusform} } ) {
33+
$nf = $message->{source}->[0];
34+
}
35+
} elsif(ref($message->{translation}->[0]) eq "") {
36+
$message->{translation}->[0] = $message->{source}->[0];
37+
}
38+
}
39+
}
40+
41+
my $xmlout = XMLout($xml, KeepRoot=>1, RootName => "TS");
42+
43+
my $out;
44+
open $out, ">i18n/qgis_en.ts";
45+
print $out "<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE TS>";
46+
binmode($out, ":utf8");
47+
print $out $xmlout;
48+
close $out;

scripts/update_ts.sh

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ if [ $action = push ]; then
122122
exit 1
123123
fi
124124
cp i18n/qgis_en.ts /tmp/qgis_en.ts-downloaded
125+
perl scripts/ts-clear.pl # reset English translations
125126
elif [ $action = pull ]; then
126127
rm i18n/qgis_*.ts
127128

0 commit comments

Comments
 (0)