Bug#657557: [PATCH 3/4] Add support for --english-only to parse-translations.
That makes it possible to extract the long descriptions from English
translations since they got dropped from Packages files in some suites.
---
bin/parse-translations | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/bin/parse-translations b/bin/parse-translations
index d079b7f..00611a9 100755
--- a/bin/parse-translations
+++ b/bin/parse-translations
@@ -39,6 +39,17 @@ use Packages::Config qw( $TOPDIR $DBDIR @DDTP_LANGUAGES );
&Packages::Config::init( './' );
my %descriptions = ();
+# Make it possible to deal with either only English translations (to
+# get long descriptions back), or all of them (the default). Since a
+# single option needs to be supported, don't bother with getopt:
+my @langs = @DDTP_LANGUAGES;
+my $output = 'descriptions_translated';
+my $argument = shift @ARGV;
+if ($argument and $argument eq '--english-only') {
+ $output = 'descriptions_translated_english_only';
+ @langs = ('en');
+}
+
$/ = "";
-d $DBDIR || mkpath( $DBDIR );
@@ -50,7 +61,7 @@ my $fixja = Text::Iconv->new("EUC-JP", "UTF-8");
# FIXME: unhardcode dists name
my @dists = ('sid', 'wheezy', 'squeeze', 'lenny');
-foreach my $lang (@DDTP_LANGUAGES) {
+foreach my $lang (@langs) {
(my $locale = $lang) =~ s/^([a-z]{2})-([a-z]{2})$/"$1_".uc($2)/e;
print "Reading Translations for $lang ($locale)...";
my $count = 0;
@@ -87,7 +98,7 @@ close PKG;
print "Writing database (".scalar(keys %descriptions)." unique descriptions)...\n";
my %descriptions_db;
-tie %descriptions_db, "DB_File", "$DBDIR/descriptions_translated.db.new",
+tie %descriptions_db, "DB_File", "$DBDIR/$output.db.new",
O_RDWR|O_CREAT, 0666, $DB_BTREE
or die "Error creating DB: $!";
while (my ($md5, $v) = each(%descriptions)) {
@@ -104,5 +115,5 @@ while (my ($md5, $v) = each(%descriptions)) {
}
untie %descriptions_db;
-rename("$DBDIR/descriptions_translated.db.new",
- "$DBDIR/descriptions_translated.db");
+rename("$DBDIR/$output.db.new",
+ "$DBDIR/$output.db");
--
1.7.2.5
Reply to: