diff options
-rw-r--r-- | find-lang.pl | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/find-lang.pl b/find-lang.pl index f12af1f..57f4b7a 100644 --- a/find-lang.pl +++ b/find-lang.pl @@ -34,23 +34,26 @@ my %finallist; # filename => attr, easy way to perform uniq File::Find::find( sub { my $file = substr($File::Find::name, length($buildroot)); + -f $File::Find::name or return; + debug("next file is %s", $file); my ($pkg, $lang, $parent); if ($file =~ m:^((.*/share/locale)/([^/_@]+)[^/]*).*/([^/]+)\.mo:) { if ($withoutmo) { return; } ($pkg, $lang, $parent) = ($4, $3, $2); - } elsif ($file =~ m:^(.*/gnome/help/([^/]+))/([^/_]+)$:) { + } elsif ($file =~ m:^(.*/gnome/help/([^/]+))/([^/_]+).*$:) { if (!$withgnome) { return; } ($pkg, $lang, $parent) = ($2, $3, $1); - } elsif ($file =~ m:^(.*/doc/kde/HTML)/([^/_@]+)[^/]*/([^/]+)$:) { + print "$pkg, $lang, $parent\n"; + } elsif ($file =~ m:^(.*/doc/kde/HTML)/([^/_@]+)[^/]*/([^/]+)/.*$:) { if (!$withkde) { return; } ($pkg, $lang, $parent) = ($2, $3, $1); - } elsif ($file =~ m:^(.*/doc/HTML)/([^/_@]+)[^/]*/([^/]+)$:) { + } elsif ($file =~ m:^(.*/doc/HTML)/([^/_@]+)[^/]*/([^/_]+).*$:) { if (!$withhtml) { return; } @@ -67,16 +70,10 @@ File::Find::find( if (! ((grep { $_ eq $pkg } @searchname) || $allname)) { return; } - my $rpmlang = $lang eq 'C' ? "" : "%lang($lang)"; - parent_to_own($parent, $file, $rpmlang); - if (defined($finallist{$file})) { - # Own multiple time, match all lang, so no %lang() - $finallist{$file} = ""; - } else { - $finallist{$file} = "$rpmlang "; - } - debug("File %s will be %s", $file, $finallist{$file}); + parent_to_own($parent, $file, $lang); + $finallist{$file}{'lang'}{$lang} = 1; + debug("File %s will be %s", $file, $lang); }, $buildroot || '/' @@ -84,8 +81,18 @@ File::Find::find( open(my $hlang, '>', "$pkgname.lang") or die "canno't open $pkgname.lang\n"; -foreach (sort keys %finallist) { - print $hlang "$finallist{$_}$_\n"; +foreach my $f (sort keys %finallist) { + my ($lang, @otherlang) = keys %{ $finallist{$f}{'lang'} || {}}; + my $l = sprintf("%s%s%s", + $finallist{$f}{'dir'} ? '%dir ' : '', + @otherlang == 0 && $lang && !$finallist{$f}{'dir'} + ? "%lang($lang) " + : '', # skeep if multiple lang + $f + ); + debug('OUT: %s', $l); + print $hlang "$l\n"; + } close($hlang); @@ -98,12 +105,8 @@ sub parent_to_own { pop(@subdir); while (my $part = shift(@subdir)) { $parent .= "/$part"; - if (defined($finallist{$parent})) { - # Own multiple time, match all lang, so no %lang() - $finallist{$parent} = "%dir "; - } else { - $finallist{$parent} = "$lang %dir "; - } - debug("Parent %s will be %s", $parent, $finallist{$parent}); + $finallist{$parent}{dir} = 1; + $finallist{$file}{'lang'}{$lang} = 1; + debug("Parent %s will be %s", $parent, $lang); } } |