-
Notifications
You must be signed in to change notification settings - Fork 292
/
update-translations.pl
executable file
·35 lines (29 loc) · 885 Bytes
/
update-translations.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
use strict;
# nasty mapping table
my $LMAP = {
'el' => 'el-rGR',
'eu' => 'eu-rES',
'fa_IR' => 'fa-rIR',
'zh_CN' => 'zh-rCN',
'zh_TW' => 'zh-rTW',
'pt_BR' => 'pt-rBR',
'hu_HU' => 'hu',
'it_IT' => 'it',
'pl_PL' => 'pl',
'id' => 'in',
'he_IL' => 'iw',
};
die "Stale 'translations'-dir exists\n" if -d 'translations';
system("transifex pull -a -w 30 --minimum-perc=30");
foreach my $src_file (glob("translations/vanilla-music-1.en-strings/*.xml")) {
if ($src_file =~ /\/([a-zA-Z_]+)\.xml/) {
my $locale = $1;
$locale = $LMAP->{$locale} if exists $LMAP->{$locale};
my $dst_file = "app/src/main/res/values-$locale/translatable.xml";
warn "+ $src_file -> $dst_file\n";
die "Unknown locale: '$locale', target=$dst_file\n" unless -f $dst_file;
rename($src_file, $dst_file) or die "rename failed: $!\n";
}
}
system("rm -rf translations");