=head1 SYNOPSIS
+ # Run this normally, hopefully...
merge-from-translatewiki --locales-dir=config/locales
# Diff the existing files:
The locales dir we'll merge stuff into. E.g. C<config/locales>.
+=item --only-new
+
+Only import translations that don't exists for us yet.
+
=back
=head1 AUTHOR
)->getoptions(
'h|help' => \my $help,
'locales-dir=s' => \my $locales_dir,
+ 'only-new' => \my $only_new,
) or help();
# On --help
my $expanded = expand_hash($translatewiki_translations{$translatewiki_lang});
my $out = +{ $rails_lang => $expanded };
spit_out($out_file, $out);
- } elsif (ref $my_translations{$translatewiki_lang} eq 'HASH') {
- say STDERR "$rails_lang has existing translations. Merging";
+ } elsif (ref $my_translations{$translatewiki_lang} eq 'HASH' and not $only_new) {
+ say STDERR "$rails_lang has existing translations. Merging the old translation with the new Translatewiki one";
# Get the data
my %tw = %{ $translatewiki_translations{$translatewiki_lang} };
exists $en{ $me_k . '.few' } or
exists $en{ $me_k . '.other' } or
exists $en{ $me_k . '.two' })) {
- say STDERR "Bringing back nuked plural form '$me_k' Setting it to '$me{ $me_k }'";
+ #say STDERR "Bringing back nuked plural form '$me_k' Setting it to '$me{ $me_k }'";
$new{ $me_k } = $me{ $me_k };
}
}
my $expanded = expand_hash( \%new );
my $out = +{ $rails_lang => $expanded };
spit_out($out_file, $out);
- } else {
+ } elsif (not $only_new) {
die "Internal error on $translatewiki_lang";
}
}
my $yaml_out = Dump $data;
open my $fh, ">", $file;
- say $fh "# Imported at " . (scalar localtime) . " from Translatewiki.net";
print $fh $yaml_out;
close $fh;
}
}
my %translatewiki_languages;
- say "All languages are: @languages";
+ my $all_count = scalar @languages;
+ say "Translatewiki has $all_count languages I'm about to get";
+ my $count = 0;
for my $lang (@languages) {
- say STDERR "Getting language $lang from Translatewiki";
+ $count ++;
+ say STDERR "Getting language $count/$all_count ($lang) from Translatewiki";
my $yaml = get_language_from_translatewiki($lang);
my $flat_data = load_and_flatten_yaml($yaml);