~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to extensions/enigmail/util/fixlang.pl

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
sub trim { # ($str)
4
 
  my $str = @_[0];
5
 
 
6
 
  $str =~ s/\s*$//;
7
 
  $str =~ s/^\s*//;
8
 
 
9
 
  return $str;
10
 
}
11
 
 
12
 
# Load DTD file
13
 
sub loaddtd { # ($file)
14
 
  my $file = @_[0];
15
 
 
16
 
  #print "+ Loading $file\n";
17
 
  my $tab={};
18
 
  my $line=0;
19
 
 
20
 
 
21
 
  my $fic;
22
 
  my $ind;
23
 
  my $val;
24
 
 
25
 
  open($fic, $file) || die "Could not open $file";
26
 
  my $prev=0;
27
 
 
28
 
  while (<$fic>) {
29
 
    my $buf = $_;
30
 
    ++$line;
31
 
    $buf =~ s/\n//;
32
 
    $buf =~ s/\r//;
33
 
    if (length(trim($buf)) == 0) {
34
 
      # print "+ empty\n";
35
 
    }
36
 
    elsif ($buf =~ /^<!ENTITY (.*)"(.*)">\s*$'/i) {
37
 
      $ind=trim($1);
38
 
      # print "+ Line  '$ind'\n";
39
 
      $val=$2;
40
 
      if ($ind eq "enigmail.ruleEmail.tooltip"
41
 
          || $ind eq "enigmail.noHushMailSupport.label"
42
 
          || $ind eq "enigmail.noHushMailSupport.tooltip") {
43
 
        $val =~ s/\</&lt;/g;
44
 
        $val =~ s/\>/&gt;/g;
45
 
      }
46
 
      $tab->{$ind} = "$1\"$val\">";
47
 
      $prev=0;
48
 
    }
49
 
    elsif ($buf =~ /^<!ENTITY (.*)"(.*)$/i) {
50
 
      $ind=trim($1);
51
 
      # print "+ Start '$ind'\n";
52
 
      $tab->{$ind} = "$1\"$2";
53
 
      $prev=$ind;
54
 
    }
55
 
    elsif ($prev && $buf =~ /^(.*)">$/) {
56
 
      # print "+ End   '$prev'\n";
57
 
      $tab->{$prev} .= "\n$1\">";
58
 
      $prev=0;
59
 
    }
60
 
    elsif ($prev) {
61
 
      # print "+ Cont. '$prev'\n";
62
 
      $tab->{$prev} .= "\n$buf";
63
 
    }
64
 
    else {
65
 
      die ("- in $file on line $line: unknown ($buf) !\n");
66
 
    }
67
 
  }
68
 
  close($fic);
69
 
 
70
 
  return $tab;
71
 
}
72
 
 
73
 
# Load properties file
74
 
sub loadprop { # ($file)
75
 
 
76
 
  my $file = @_[0];
77
 
 
78
 
  #print "+ Loading $file\n";
79
 
  my $tab={};
80
 
 
81
 
  my $fic;
82
 
  my $ind;
83
 
 
84
 
  open($fic, $file) || die "Could not open $file";
85
 
 
86
 
  while (<$fic>) {
87
 
    my $buf = $_;
88
 
    $buf =~ s/\n//;
89
 
    $buf =~ s/\r//;
90
 
 
91
 
    if (length(trim($buf)) == 0) {
92
 
      #print "+ empty\n";
93
 
    }
94
 
    elsif ($buf =~ /^\s*#/) {
95
 
      #print "+ comments\n";
96
 
    }
97
 
    elsif ($buf =~ /^\s*([A-Za-z0-9._]+)\s*=\s*(.*)/) {
98
 
      #print "+ Value '$1'\n";
99
 
      $ind=trim($1);
100
 
      $tab->{$ind} = "$1=$2";
101
 
    }
102
 
    else {
103
 
      print ("\tIgnored ($buf) !\n");
104
 
    }
105
 
  }
106
 
 
107
 
  return $tab;
108
 
}
109
 
 
110
 
 
111
 
($#ARGV > 0) || die ("usage fixlang.pl fromdir destdir\n   fromdir: original en-US locale directory\n   destdir: locale lanugage dir\n");
112
 
my $from=$ARGV[0];
113
 
my $dest=$ARGV[1];
114
 
 
115
 
(-f "$from/enigmail.dtd")        || die ("$from/enigmail.dtd not found\n");
116
 
(-f "$dest/enigmail.dtd")        || die ("$dest/enigmail.dtd not found\n");
117
 
(-f "$from/enigmail.properties") || die ("$from/enigmail.properties not found\n");
118
 
(-f "$dest/enigmail.properties") || die ("$dest/enigmail.properties not found\n");
119
 
 
120
 
my $endtd = loaddtd("$from/enigmail.dtd");
121
 
my $frdtd = loaddtd("$dest/enigmail.dtd");
122
 
 
123
 
print "+ Writing $dest/enigmail.dtd\n";
124
 
open(OUT, ">$dest/enigmail.dtd")  || die "Cannot write to $dest/enigmail.dtd";
125
 
 
126
 
for my $ind (keys %$endtd) {
127
 
 
128
 
  if ($frdtd->{$ind}) {
129
 
    print OUT "<!ENTITY $frdtd->{$ind}\n";
130
 
  }
131
 
  else {
132
 
    print "\tAdding missing $ind\n";
133
 
    print OUT "<!ENTITY $endtd->{$ind}\n";
134
 
  }
135
 
}
136
 
 
137
 
close(OUT);
138
 
 
139
 
my $enprop = loadprop("$from/enigmail.properties");
140
 
my $frprop = loadprop("$dest/enigmail.properties");
141
 
 
142
 
print "+ Writing $dest/enigmail.properties\n";
143
 
open(OUT, ">$dest/enigmail.properties") || die "Cannot write to $dest/enigmail.properties";
144
 
for my $ind (keys %$enprop) {
145
 
  if ($frprop->{$ind}) {
146
 
    print OUT "$frprop->{$ind}\n";
147
 
  } else {
148
 
    print "\tAdding missing $ind\n";
149
 
    print OUT "$enprop->{$ind}\n";
150
 
  }
151
 
}
152
 
close(OUT);
153
 
 
154