~ubuntu-branches/ubuntu/maverick/kubuntu-docs/maverick

« back to all changes in this revision

Viewing changes to debian/prepare-firefox-startpage-translations

  • Committer: Bazaar Package Importer
  • Author(s): Richard A. Johnson
  • Date: 2008-08-18 10:49:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080818104914-83r2er2hsmdp2o0l
Tags: 8.10-2
* Restructured kubuntu documentation package
  - Refer to the NEWS text located in the root directory of the package
* Removed the Firefox start page files
* debian/rules: updated to remove firefox files
* debian/control: removed perl deps due to removal of firefox files, bumped
  version to 3.8.0, updated kdelibs-data dep to kdelibs5-data

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
# used by *ubuntu-docs packages
3
 
 
4
 
use strict qw(refs);
5
 
use POSIX;
6
 
our ($yes); map { $yes{$_}=1 }
7
 
#******************************************************************************
8
 
#****  read DapperFirefoxStartPageTranslation before changing this list !  ****
9
 
    qw(
10
 
 
11
 
       ar bg_BG bn bn_IN ca cs_CZ da_DK de de_DE el en_GB es es_AR
12
 
       es_ES eu fi_FI fr fr_FR ga_IE gl gu_IN he_IL hu_HU it_IT ja_JP
13
 
       ko ku lt mk_MK mn nb_NO nl nl_NL pa_IN pl_PL pt pt_BR ro_RO ru_RU
14
 
       sk sl_SI sv_SE tr_TR zh_CN zh_TW
15
 
 
16
 
       )
17
 
#****  read DapperFirefoxStartPageTranslation before changing this list !  ****
18
 
#******************************************************************************
19
 
    ;
20
 
 
21
 
$0 =~ s,.*/,,;
22
 
$usage= <<END;
23
 
$0 is a tool to help with
24
 
 http://wiki.ubuntu.com/DapperFirefoxStartPageTranslation
25
 
 
26
 
$0 --list
27
 
  print list of translateable locales
28
 
 
29
 
$0 LOCALE
30
 
  maps LOCALE to best translateable locale (`-' means en_US)
31
 
 
32
 
$0 SRCDIR PKGSTAGING ALTDIR DSTPATH ENUSLINKSRC
33
 
  for use in debian/rules of a *ubuntu-docs package
34
 
  installs index-*.html files and symlinks.
35
 
   SRCDIR       the directory containing all the index-*.html files
36
 
                 (not symlinks) which are the available translations
37
 
   PKGSTAGING   directory (eg debian/ubuntu-docs) where the package is
38
 
                 being constructed
39
 
   ALTDIR       DapperFirefoxStartPageTranslation's ALTDIR, incl. leading /
40
 
   ENUSLINKSRC  symlink text to use for untranslated but translateable
41
 
                 locales; should be a relative link from ALTDIR to
42
 
                 to the default en_US start page
43
 
END
44
 
 
45
 
$yes{'C'}= 1;
46
 
 
47
 
#---------- and now the program: ----------
48
 
 
49
 
sub maplocale ($\%) {
50
 
    my ($l,$ehash) = @_;
51
 
    return $l if exists $ehash->{$l};
52
 
    if ($l =~ s/_.*$//) { return $l if exists $ehash->{$l}; }
53
 
    $l= $l.'_'.uc $l;
54
 
    return $l if exists $ehash->{$l};
55
 
    return '';
56
 
}
57
 
 
58
 
if (@ARGV==1) {
59
 
    our ($want) = @ARGV;
60
 
    if ($want eq '--list') {
61
 
        print join(' ', sort keys %yes),"\n" or die $!;
62
 
    } elsif ($want =~ m/^\-/) {
63
 
        die "$0; unknown option \`$want'\n";
64
 
    } else {
65
 
        our ($got) = maplocale($want, %yes);
66
 
        $got='-' if $got eq '';
67
 
        print "$got\n" or die $!;
68
 
    }
69
 
} elsif (@ARGV==4) {
70
 
    our ($srcdir, $pkgstaging, $altdir, $enuslinksrc) = @ARGV;
71
 
    our (@files, %file, $want, $got, $dstpath, $linksrc, $linkdst);
72
 
    @files= glob "$srcdir/index-*.html";
73
 
    $dstpath= $pkgstaging.$altdir;
74
 
    $!=0; system('install','-m755','-oroot','-groot','-d',$dstpath)
75
 
        and die "$0: create $dstpath: $? $!\n";
76
 
    if (@files) {
77
 
        $!=0; system('install','-m644','-oroot','-groot',@files,"$dstpath/.")
78
 
            and die "$0: install @files in $dstpath: $? $!\n";
79
 
    }
80
 
    map { m,index-([^/]+)\.html$, or die; $file{$1}=0; } @files;
81
 
    foreach $want (sort keys %yes) {
82
 
        $got= maplocale($want, %file);
83
 
        if (length $got) {
84
 
            $file{$got}++;
85
 
            $linksrc= "index-$got.html";
86
 
        } else {
87
 
            $linksrc= $enuslinksrc;
88
 
        }
89
 
        push @map, [ $want, ($got eq $want ? "=    " :
90
 
                             length $got ? "-> $got" : "-> -") ];
91
 
        next if $want eq $got;
92
 
        $linkdst= "$dstpath/index-$want.html";
93
 
        remove($linkdst) or $!==&ENOENT or die "$0: remove old $linkdst: $!\n";
94
 
        symlink($linksrc, $linkdst)
95
 
            or die "$0: symlink $linksrc $linkdst: $!\n";
96
 
    }
97
 
    our $cols=4;
98
 
    our $rows= ceil(@map / $cols);
99
 
    for ($row=0; $row<$rows; $row++) {
100
 
        for ($col=0, $i=$col*$rows + $row;
101
 
             $col<$cols && $i<@map;
102
 
             $i+=$rows, $col++) {
103
 
            printf "%s %-5s %s", ($col?"\t":""), @{$map[$i]} or die $!;
104
 
        }
105
 
        print "\n" or die $!;
106
 
    }
107
 
    foreach $got (keys %file) {
108
 
        next if $file{$got} >= 1;
109
 
        print STDERR "$0: installed unuseable translation for $got\n";
110
 
    }
111
 
} else {
112
 
    die "$0: bad usage\n\n$usage\n";
113
 
}