File: dbl10n.pl

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (55 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w -- # -*- Perl -*-

use strict;

my $template = "dbl10n.template";
my $dbl10n   = "dbl10n.dsl";
my @languages = ();
my %langsection = ();
my $inlist = 0;
my $historical = 0;

open (F, $template);
open (G, ">$dbl10n");

while (<F>) {
    if (/\%\%\/?LANGUAGES\%\%/ || /\%\%HISTORICAL\%\%/) {
	$inlist = 1 if $& eq '%%LANGUAGES%%';
	$inlist = 0 if $& eq '%%/LANGUAGES%%';
	$historical = 1 if $& eq '%%HISTORICAL%%';
	next;
    }

    if ($inlist && /^;; (\S+)\s+-/) {
	my $lang = $1;
	my $section = $1;

	if ($historical) {
	    $lang =~ /^(\S+)\((\S+)\)/;
	    $lang = $1;
	    $section = $2;
	}

	$section =~ s/\_//sg;
#	print "$lang = $section\n";

	push (@languages, $lang);
	$langsection{$lang} = $section;
    }

    if (/<!\[\%l10n-XX/) {
	my $line = $_;
	foreach my $lang (@languages) {
	    my $section = $langsection{$lang};
	    $_ = $line;
	    s/\"XX\"/\"$lang\"/g;
	    s/XX/$section/g;
	    print G $_;
	}
    } else {
	print G $_;
    }
}

close (F);
close (G);