Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 107 lines (81 sloc) 1.504 kB
a392693 @angelortega New binary art5.
authored
1 #!/usr/bin/perl
2
f6fcd83 @angelortega Renamed Artemus5.pm to Art5.pm.
authored
3 use Art5;
a392693 @angelortega New binary art5.
authored
4
5 my $dump = 0;
6 my $v, $s;
5bde294 @angelortega Some fixes to art5.
authored
7 my @path = ();
a392693 @angelortega New binary art5.
authored
8
9 # raw argument parsing
10 while ($v = shift(@ARGV)) {
11 if ($v eq '-d') {
12 $dump = 1;
13 }
5bde294 @angelortega Some fixes to art5.
authored
14 elsif ($v eq '-I') {
15 push(@path, shift(@ARGV));
16 }
80dd372 @angelortega Start of implementation of -l in art5.
authored
17 elsif ($v eq '-l') {
18 update_lang();
19 }
a392693 @angelortega New binary art5.
authored
20 else {
21 # script name
22 }
23 }
24
25 if (!defined($s)) {
5bde294 @angelortega Some fixes to art5.
authored
26 $s = join('', <>);
a392693 @angelortega New binary art5.
authored
27 }
28
45e71cc @angelortega If there is a cache directory, save there all compiled code.
authored
29 my $a = Art5->new( path => \@path, cache => '/tmp/art5/');
a392693 @angelortega New binary art5.
authored
30
31 my $c = $a->compile($s);
32
33 if ($dump) {
34 use Data::Dumper;
35
5bde294 @angelortega Some fixes to art5.
authored
36 print Dumper($c), "\n";
a392693 @angelortega New binary art5.
authored
37 }
38 else {
39 print $a->exec($c);
40 }
41
42 exit 0;
80dd372 @angelortega Start of implementation of -l in art5.
authored
43
44 sub update_lang
45 # updates all language files
46 {
47 my @lang = glob("lang_*");
48
49 if (scalar(@lang) == 0) {
50 print "Error: no lang_* files.\n";
51 exit 1;
52 }
53
54 # read now all templates in the current directory
55 # searching for translateable strings
56 my %h = ();
57
58 foreach my $t (glob("*")) {
59 # skip language files themselves
60 if ($t =~ /lang_.*$/) {
61 next;
62 }
63
64 # read template
65 if (open F, $t) {
66 my $l;
67
68 while ($l = <F>) {
69 my @s = ($l =~ /@\"([^\"]+)"/g);
70
71 foreach my $s (@s) {
72 $h{$s}++;
73 }
74 }
75
76 close F;
77 }
78 }
79
a3818a6 @angelortega Finished language translation tool in art5.
authored
80 my $a = Art5->new( path => ['.']);
81
80dd372 @angelortega Start of implementation of -l in art5.
authored
82 # now all keys in the templates must be
83 # merged into each language file
84 # ...
85
a3818a6 @angelortega Finished language translation tool in art5.
authored
86 foreach my $l (@lang) {
87 print "Rebulding $l...\n";
88
89 # load and execute this template file
90 my $c = $a->code($l);
91 $a->exec($c);
92
93 open F, ">$l";
94
95 print F "<{T\n";
96 foreach my $k (sort keys(%h)) {
97 print F "\"$k\" \n";
98 print F "\"", ($a->{t}->{$k} || ''), "\"\n\n";
99 }
100 print F "}>\n";
101
102 close F;
80dd372 @angelortega Start of implementation of -l in art5.
authored
103 }
104
105 exit 0;
106 }
Something went wrong with that request. Please try again.