build: add script to merge master translation into branches
authorJo-Philipp Wich <jo@mein.io>
Wed, 29 Jan 2020 07:29:17 +0000 (08:29 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 29 Jan 2020 07:40:30 +0000 (08:40 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
build/i18n-merge-master.pl [new file with mode: 0755]

diff --git a/build/i18n-merge-master.pl b/build/i18n-merge-master.pl
new file mode 100755 (executable)
index 0000000..d7479ef
--- /dev/null
@@ -0,0 +1,17 @@
+#!/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;
+               system("git show --format=\%B 'master:$path' > '$ref'");
+               system('msgmerge', '-N', '-o', $path, $ref, $path);
+               system('msgattrib', '--no-obsolete', '-o', $path, $path);
+               unlink($ref);
+       }
+
+       close F;
+}