From 9f1199c4ae6fb31592a2414496fcc9df41935dd6 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 7 Jan 2008 16:44:50 +0000 Subject: [PATCH] =?utf8?q?1.=20Erweiterte=20HTML-Template-Checks=20nur=20d?= =?utf8?q?urchf=C3=BChren,=20wenn=20Parameter=20"-h"=20angegeben=20wird.?= =?utf8?q?=202.=20Weitere=20Checks=20f=C3=BCr=20HTML-Templates:=20Suche=20?= =?utf8?q?nach=20Master-Templates,=20die=20von=20keiner=20anderen=20Datei?= =?utf8?q?=20referenziert=20wurden=20und=20Suche=20nach=20=C3=BCbersetzten?= =?utf8?q?=20Templates,=20f=C3=BCr=20die=20es=20keinen=20Master=20gibt.=20?= =?utf8?q?3.=20Anzeige=20der=20Namen=20um=20unwichtige=20Prefixe=20gek?= =?utf8?q?=C3=BCrzt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- locale/de/locales.pl | 64 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/locale/de/locales.pl b/locale/de/locales.pl index a754c7cea..313dc9c63 100755 --- a/locale/de/locales.pl +++ b/locale/de/locales.pl @@ -19,6 +19,13 @@ $dbupdir2 = "$basedir/sql/Pg-upgrade2"; $menufile = "menu.ini"; $submitsearch = qr/type\s*=\s*[\"\']?submit/i; +%referenced_html_files = (); + +# Arguments: +# -v verbose +# -n no custom files +# -h extended checks on HTML templates + foreach $item (@ARGV) { $item =~ s/-//g; $arg{$item} = 1; @@ -242,6 +249,11 @@ close(FH); $trlanguage = $language[0]; chomp $trlanguage; +if ($arg{h}) { + search_unused_htmlfiles(); + search_translated_htmlfiles_wo_master(); +} + $per = sprintf("%.1f", ($count - $notext) / $count * 100); print "\n$trlanguage - ${per}%"; print " - $notext missing" if $notext; @@ -343,8 +355,8 @@ sub scanfile { # &converthtmlfile($newfile); $cached{$file}{scanh}{$newfile} = 1; print "." if $arg{v}; - } else { - print "W: missing HTML template: $newfile (referenced from $file)\n"; + } elsif ($arg{h}) { + print "W: missing HTML template: " . strip_base($newfile) . " (referenced from " . strip_base($file) . ")\n"; } } @@ -429,6 +441,8 @@ sub scanfile { map { &scanfile($_, 0, $scanned_files) } keys %{$cached{$file}{scan}}; map { &scanfile($_, 1, $scanned_files) } keys %{$cached{$file}{scannosubs}}; map { &scanhtmlfile($_) } keys %{$cached{$file}{scanh}}; + + @referenced_html_files{keys %{$cached{$file}{scanh}}} = (1) x scalar keys %{$cached{$file}{scanh}}; } sub scanmenu { @@ -574,3 +588,49 @@ sub converthtmlfile { close(IN); close(OUT); } + +sub search_unused_htmlfiles { + my @unscanned_dirs = ('../../templates/webpages'); + + while (scalar @unscanned_dirs) { + my $dir = shift @unscanned_dirs; + + foreach my $entry (<$dir/*>) { + if (-d $entry) { + push @unscanned_dirs, $entry; + + } elsif (($entry =~ /_master.html$/) && -f $entry && !$referenced_html_files{$entry}) { + print "W: unused HTML template: " . strip_base($entry) . "\n"; + + } + } + } +} + +sub search_translated_htmlfiles_wo_master { + my @unscanned_dirs = ('../../templates/webpages'); + + while (scalar @unscanned_dirs) { + my $dir = shift @unscanned_dirs; + + foreach my $entry (<$dir/*>) { + if (-d $entry) { + push @unscanned_dirs, $entry; + + } elsif (($entry =~ /_[a-z]+\.html$/) && ($entry !~ /_master.html$/) && -f $entry) { + my $master = $entry; + $master =~ s/[a-z]+\.html$/master.html/; + if (! -f $master) { + print "W: translated HTML template without master: " . strip_base($entry) . "\n"; + } + } + } + } +} + +sub strip_base { + $_[0] =~ s|^../../||; + $_[0] =~ s|templates/webpages/||; + + return $_[0]; +} -- 2.20.1