use FileHandle;
use Data::Dumper;
+use List::Util qw(first);
+
$| = 1;
$basedir = "../..";
require "all";
}
+my %old_texts = %{ $self->{texts} };
+
# Read HTML templates.
#%htmllocale = ();
#@htmltemplates = <../../templates/webpages/*/*_master.html>;
}
+@lost = ();
+
+if (-f "lost") {
+ require "lost";
+ unlink "lost";
+}
+
+while (($text, $translation) = each %old_texts) {
+ next if ($alllocales{$text});
+
+ push @lost, { 'text' => $text, 'translation' => $translation };
+}
+
+if (scalar @lost) {
+ splice @lost, 0, (scalar @lost - 50) if (scalar @lost > 50);
+
+ open FH, ">lost";
+ print FH "#!/usr/bin/perl\n\n" .
+ "# The last 50 texts that have been removed.\n" .
+ "# This file will be auto-generated by locales.pl. Do not edit it.\n\n" .
+ "\@lost = (\n";
+
+ foreach $entry (@lost) {
+ $entry->{text} =~ s/\'/\\\'/;
+ $entry->{translation} =~ s/\'/\\\'/;
+ print FH " { 'text' => '$entry->{text}', 'translation' => '$entry->{translation}' },\n";
+ }
+
+ print FH ");\n\n1;\n";
+ close FH;
+}
+
open(FH, "LANGUAGE");
@language = <FH>;
close(FH);
sub scanhtmlfile {
local *IN;
-
+
if (!defined $cached{$_[0]}) {
-
+ my %plugins = ( 'loaded' => { }, 'needed' => { } );
+
open(IN, $_[0]) || die $_[0];
my $copying = 0;
while (my $line = <IN>) {
chomp($line);
+ while ($line =~ m/\[\%[^\w]*use[^\w]+(\w+)[^\w]*?\%\]/gi) {
+ $plugins{loaded}->{$1} = 1;
+ }
+
+ while ($line =~ m/\[\%[^\w]*(\w+)\.\w+\(/g) {
+ my $plugin = $1;
+ $plugins{needed}->{$plugin} = 1 if (first { $_ eq $plugin } qw(HTML LxERP JavaScript MultiColumnIterator));
+ }
+
while ("" ne $line) {
if (!$copying) {
if ($line =~ m|<translate>|i) {
}
close(IN);
+
+ foreach my $plugin (keys %{ $plugins{needed} }) {
+ next if ($plugins{loaded}->{$plugin});
+ print "E: " . strip_base($_[0]) . " requires the Template plugin '$plugin', but is not loaded with '[\% USE $plugin \%]'.\n";
+ }
+
&converthtmlfile($_[0]);
}