Revision ec047e71
Von Moritz Bunkus vor etwa 16 Jahren hinzugefügt
locale/de/locales.pl | ||
---|---|---|
6 | 6 |
# this version of locles processes not only all required .pl files |
7 | 7 |
# but also all parse_html_templated files. |
8 | 8 |
|
9 |
use POSIX; |
|
10 |
use FileHandle; |
|
11 | 9 |
use Data::Dumper; |
12 |
|
|
10 |
use FileHandle; |
|
11 |
use Getopt::Long; |
|
13 | 12 |
use List::Util qw(first); |
13 |
use POSIX; |
|
14 |
use Pod::Usage; |
|
14 | 15 |
|
15 | 16 |
$| = 1; |
16 | 17 |
|
... | ... | |
23 | 24 |
|
24 | 25 |
%referenced_html_files = (); |
25 | 26 |
|
26 |
# Arguments: |
|
27 |
# -v verbose |
|
28 |
# -n no custom files |
|
29 |
# -h extended checks on HTML templates |
|
27 |
my $opt_v = 0; |
|
28 |
my $opt_n = 0; |
|
29 |
my $opt_c = 0; |
|
30 |
|
|
31 |
sub parse_args { |
|
32 |
my ($help, $man); |
|
30 | 33 |
|
31 |
foreach $item (@ARGV) { |
|
32 |
$item =~ s/-//g; |
|
33 |
$arg{$item} = 1; |
|
34 |
GetOptions('no-custom-files' => \$opt_n, |
|
35 |
'check-files' => \$opt_c, |
|
36 |
'verbose' => \$opt_v, |
|
37 |
'help' => \$help, |
|
38 |
'man' => \$man,); |
|
39 |
|
|
40 |
if ($help) { |
|
41 |
pod2usage(1); |
|
42 |
exit 0; |
|
43 |
} |
|
44 |
|
|
45 |
if ($man) { |
|
46 |
pod2usage(-exitstatus => 0, -verbose => 2); |
|
47 |
exit 0; |
|
48 |
} |
|
34 | 49 |
} |
35 | 50 |
|
51 |
parse_args(); |
|
52 |
|
|
36 | 53 |
opendir DIR, "$bindir" or die "$!"; |
37 | 54 |
@progfiles = grep { /\.pl$/ && !/(_|^\.)/ } readdir DIR; |
38 | 55 |
seekdir DIR, 0; |
... | ... | |
40 | 57 |
closedir DIR; |
41 | 58 |
|
42 | 59 |
# put customized files into @customfiles |
43 |
@customfiles = () if ($arg{n}); |
|
44 | 60 |
|
45 |
if ($arg{n}) { |
|
46 |
@menufiles = ($menufile); |
|
61 |
if ($opt_n) { |
|
62 |
@customfiles = (); |
|
63 |
@menufiles = ($menufile); |
|
47 | 64 |
} else { |
48 | 65 |
opendir DIR, "$basedir" or die "$!"; |
49 | 66 |
@menufiles = grep { /.*?_$menufile$/ } readdir DIR; |
... | ... | |
79 | 96 |
|
80 | 97 |
sub handle_file { |
81 | 98 |
my ($file, $dir) = @_; |
82 |
print "\n$file" if $arg{v};
|
|
99 |
print "\n$file" if $opt_v;
|
|
83 | 100 |
%locale = (); |
84 | 101 |
%submit = (); |
85 | 102 |
%subrt = (); |
... | ... | |
105 | 122 |
if ($file eq 'menunew.pl') { |
106 | 123 |
foreach $item (@menufiles) { |
107 | 124 |
&scanmenu("$basedir/$item"); |
108 |
print "." if $arg{v};
|
|
125 |
print "." if $opt_v;
|
|
109 | 126 |
} |
110 | 127 |
} |
111 | 128 |
|
... | ... | |
291 | 308 |
$trlanguage = $language[0]; |
292 | 309 |
chomp $trlanguage; |
293 | 310 |
|
294 |
if ($arg{h}) {
|
|
311 |
if ($opt_c) {
|
|
295 | 312 |
search_unused_htmlfiles(); |
296 | 313 |
search_translated_htmlfiles_wo_master(); |
297 | 314 |
} |
... | ... | |
404 | 421 |
# &scanhtmlfile($newfile); |
405 | 422 |
# &converthtmlfile($newfile); |
406 | 423 |
$cached{$file}{scanh}{$newfile} = 1; |
407 |
print "." if $arg{v};
|
|
408 |
} elsif ($arg{h}) {
|
|
424 |
print "." if $opt_v;
|
|
425 |
} elsif ($opt_c) {
|
|
409 | 426 |
print "W: missing HTML template: " . strip_base($newfile) . " (referenced from " . strip_base($file) . ")\n"; |
410 | 427 |
} |
411 | 428 |
} |
... | ... | |
702 | 719 |
|
703 | 720 |
return $s; |
704 | 721 |
} |
722 |
|
|
723 |
__END__ |
|
724 |
|
|
725 |
=head1 NAME |
|
726 |
|
|
727 |
locales.pl - Collect strings for translation in Lx-Office |
|
728 |
|
|
729 |
=head1 SYNOPSIS |
|
730 |
|
|
731 |
locales.pl [options] |
|
732 |
|
|
733 |
Options: |
|
734 |
-n, --no-custom-files Do not process files whose name contains "_" |
|
735 |
-c, --check-files Run extended checks on HTML files |
|
736 |
-v, --verbose Be more verbose |
|
737 |
-h, --help Show this help |
|
738 |
|
|
739 |
=head1 OPTIONS |
|
740 |
|
|
741 |
=over 8 |
|
742 |
|
|
743 |
=item B<-n>, B<--no-custom-files> |
|
744 |
|
|
745 |
Do not process files whose name contains "_", e.g. "custom_io.pl". |
|
746 |
|
|
747 |
=item B<-c>, B<--check-files> |
|
748 |
|
|
749 |
Run extended checks on the usage of templates. This can be used to |
|
750 |
discover HTML templates that are never used as well as the usage of |
|
751 |
non-existing HTML templates. |
|
752 |
|
|
753 |
=item B<-v>, B<--verbose> |
|
754 |
|
|
755 |
Be more verbose. |
|
756 |
|
|
757 |
=back |
|
758 |
|
|
759 |
=head1 DESCRIPTION |
|
760 |
|
|
761 |
This script collects strings from Perl files, the menu.ini file and |
|
762 |
HTML templates and puts them into the file "all" for translation. It |
|
763 |
also distributes those translations back to the individual files. |
|
764 |
|
|
765 |
=cut |
Auch abrufbar als: Unified diff
Optionen des Scripts dokumentiert.