Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 00c278b5

Von Moritz Bunkus vor mehr als 18 Jahren hinzugefügt

  • ID 00c278b5eebfd2b245a9d75021126af809318f93
  • Vorgänger 55ad9cb0
  • Nachfolger 8efe3525

Neue locales.pl, die auch HTML templates nach Funktionen durchsucht. [Merge von 1284 aus dem LINET prog Repo]

Unterschiede anzeigen:

locale/de/locales.pl
2 2

  
3 3
# -n do not include custom_ scripts
4 4

  
5
# this version of locles processes not only all required .pl files
6
# but also all parse_html_templated files.
7

  
5 8
use POSIX;
6 9
use FileHandle;
10
use Data::Dumper;
7 11

  
8 12
$basedir  = "../..";
9 13
$bindir   = "$basedir/bin/mozilla";
10 14
$menufile = "menu.ini";
15
$submitsearch = qr/type\s*=\s*["']?submit/i;
11 16

  
12 17
foreach $item (@ARGV) {
13 18
  $item =~ s/-//g;
......
38 43
}
39 44

  
40 45
# Read HTML templates.
41
%htmllocale = ();
42
@htmltemplates = <../../templates/webpages/*/*_master.html>;
43
foreach $file (@htmltemplates) {
44
  scanhtmlfile($file);
45
}
46
#%htmllocale = ();
47
#@htmltemplates = <../../templates/webpages/*/*_master.html>;
48
#foreach $file (@htmltemplates) {
49
#  scanhtmlfile($file);
50
#}
46 51

  
47 52
foreach $file (@progfiles) {
48 53

  
......
296 301
      &scanfile("$bindir/$newfile");
297 302
    }
298 303

  
304
    # is this a template call?
305
    if (/parse_html_template\s*\(\s*["']([\w\/]+)/) {
306
      my $newfile = "$basedir/templates/webpages/$1_master.html";
307
      if (-f $newfile) {
308
        &scanhtmlfile($newfile);
309
        &converthtmlfile($newfile);
310
      }
311
    }
312

  
299 313
    # is this a sub ?
300 314
    if (/^sub /) {
301 315
      ($null, $subrt) = split / +/;
......
317 331
      my $postmatch = "";
318 332

  
319 333
      # is it a submit button before $locale->
320
      if (/type\s*=\s*submit/i) {
334
      if (/$submitsearch/) {
321 335
        $postmatch = $';
322 336
        if ($` !~ /\$locale->text/) {
323 337
          $is_submit   = 1;
......
394 408
sub scanhtmlfile {
395 409
  local *IN;
396 410

  
397
  open(IN, $_[0]) || die;
411
  open(IN, $_[0]) || die $_[0];
398 412

  
399 413
  my $copying = 0;
414
  my $issubmit = 0;
400 415
  my $text = "";
401 416
  while (my $line = <IN>) {
402 417
    chomp($line);
......
404 419
    while ("" ne $line) {
405 420
      if (!$copying) {
406 421
        if ($line =~ m|<translate>|i) {
407
          substr($line, 0, $+[0]) = "";
422
          my $eom = $+[0];
423
          if ($` =~ /$submitsearch/) {
424
            $issubmit = 1
425
          }
426
          substr($line, 0, $eom) = "";
408 427
          $copying = 1;
409

  
410 428
        } else {
411 429
          $line = "";
412 430
        }
......
415 433
        if ($line =~ m|</translate>|i) {
416 434
          $text .= $`;
417 435
          substr($line, 0, $+[0]) = "";
418
          $copying = 0;
436
          
437
          $copying = 0; 
438
          if ($issubmit) {
439
            $submit{$text} = 1;
440
            $issubmit = 0;
441
          }
419 442
          $alllocales{$text} = 1;
420 443
          $htmllocale{$text} = 1;
421 444
          $text = "";
......
435 458
  local *IN;
436 459
  local *OUT;
437 460

  
438
  open(IN, $_[0]) || die;
461
  my $file = shift;
462

  
463
  open(IN, $file) || die;
439 464

  
440 465
  my $langcode = (split("/", getcwd()))[-1];
441
  $_[0] =~ s/_master.html$/_${langcode}.html/;
466
  $file =~ s/_master.html$/_${langcode}.html/;
442 467

  
443
  open(OUT, ">${_[0]}") || die;
468
  open(OUT, ">$file") || die;
444 469

  
445 470
  my $copying = 0;
446 471
  my $text = "";

Auch abrufbar als: Unified diff