>From 35a9ad5f4d757161aa631a04d0aa10d2b732a3b5 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Fri, 10 Jul 2009 12:51:38 +0200 Subject: [PATCH] Incorporate neutral language in sublang statistics if appropriate --- transl/scripts/ver.pl | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/transl/scripts/ver.pl b/transl/scripts/ver.pl index 9b7f289..1a5610f 100755 --- a/transl/scripts/ver.pl +++ b/transl/scripts/ver.pl @@ -87,6 +87,11 @@ $norm_fn =~ s/[^a-zA-Z0-9]/-/g; #$deflangs{"009:00"} = TRUE; $deflangs{"009:01"} = TRUE; +# Get just the sublangs +opendir(DIR, "$scriptsdir/conf"); +@languages = grep(!/(^\.|.:00)/, readdir(DIR)); +closedir(DIR); + while () { if (m/^TYPE NEXT/) @@ -115,7 +120,38 @@ while () if (m/^EXIST ([0-9a-f]{3}:[0-9a-f]{2})/) { $lang = collapse($1); - if (not defined $deflangs{$lang}) + + # Don't add neutral langs (nn:00) to the file_langs array + # if we have sublangs (nn:xx) in the conf directory, add + # it's sublangs instead (if present). + # + # English:Neutral (009:00) is an exception to this rule. + # + if (($lang =~ /^[0-9a-f]{3}:00/) && ($lang ne "009:00")) + { + # Find the sublangs + $primary_lang = $lang; + $primary_lang =~ s/:00//; + $found = 0; + foreach $language (@languages) + { + if ($language =~ /$primary_lang:./) + { + if (not defined $deflangs{$language}) + { + $deflangs{$language} = TRUE; + push @file_langs, $language; + } + $found = 1; + } + } + if ((!$found) && (not defined $deflangs{$lang})) + { + $deflangs{$lang} = TRUE; + push @file_langs, $lang; + } + } + elsif (not defined $deflangs{$lang}) { $deflangs{$lang} = TRUE; push @file_langs, $lang; -- 1.6.0.6