build: add i18n-merge-openwrt-19.07
authorHannu Nyman <hannu.nyman@iki.fi>
Fri, 15 May 2020 13:59:59 +0000 (16:59 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Fri, 15 May 2020 14:12:25 +0000 (17:12 +0300)
Support backporting translation strings from 19.07 to 18.06 by adding a script for that.

Targeted workflow is:
1) sync 18.06 to apps
2) backport 19.07 translations
3) re-sync 18.06 just in case
4) backport master translations
5) re-sync 18.06 just in case

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
build/i18n-merge-openwrt-1907.pl [new file with mode: 0755]

diff --git a/build/i18n-merge-openwrt-1907.pl b/build/i18n-merge-openwrt-1907.pl
new file mode 100755 (executable)
index 0000000..8691b0b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+
+if (open F, '-|', 'find', $ARGV[0] || '.', '-type', 'f', '-name', '*.po') {
+       while (defined(my $path = readline F)) {
+               chomp $path;
+
+               (my $ref = $path) =~ s/\.po$/\.master.po/;
+
+               printf 'Updating %s ', $path;
+               my $returnCode = system("git show --format=\%B 'openwrt-19.07:$path' > '$ref'");
+               if ( $returnCode == 0 )
+               {
+                       system('msgmerge', '-N', '-o', $path, $ref, $path);
+                       system('msgattrib', '--no-obsolete', '-o', $path, $path);
+               } else {
+                       print "...failed due to git error.\n";
+               }
+               unlink($ref);
+       }
+
+       close F;
+}