From 6f73d970089bd95cc620f7c27404ff67704ef5d7 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 16 Feb 2006 11:08:26 +0000 Subject: [PATCH] Die HTML-Vorlagen werden nun ebenfalls von locales.pl uebersetzt. Dabei werden alle Vorlagen mit name_master.html benannt und nach name_sprache.html ausgegeben. Der zu uebersetzende Text steht innerhalb von .... Diese Tags koennen an beliebigen Stellen vorkommen, also auch z.B. in Attributen von regulaeren HTML-Tags oder innerhalb von -Tags. --- locale/de/all | 1 + locale/de/locales.pl | 109 +++++++++++++++++- .../generic/{error.html => error_master.html} | 2 +- 3 files changed, 110 insertions(+), 2 deletions(-) rename templates/webpages/generic/{error.html => error_master.html} (65%) diff --git a/locale/de/all b/locale/de/all index 0d58917fd..99efb17a2 100644 --- a/locale/de/all +++ b/locale/de/all @@ -309,6 +309,7 @@ $self{texts} = { 'Enforce transaction reversal for all dates' => 'Gegenbuchungen für jeden Zeitraum aktualisieren', 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' => 'Geben Sie Ihre und weitere Währungen mit bis zu drei Buchstaben pro Währung und Währungen durch Doppelpunkte getrennt ein (z.B. EUR:USD:CAD)', 'Equity' => 'Passiva', + 'Error!' => 'Fehler!', 'Exch' => 'Wechselkurs.', 'Exchangerate' => 'Wechselkurs', 'Exchangerate Difference' => 'Wechselkursunterschied', diff --git a/locale/de/locales.pl b/locale/de/locales.pl index f5cd120b0..ac2494758 100755 --- a/locale/de/locales.pl +++ b/locale/de/locales.pl @@ -2,6 +2,7 @@ # -n do not include custom_ scripts +use POSIX; use FileHandle; $basedir = "../.."; @@ -36,6 +37,13 @@ if (-f 'all') { require "all"; } +# Read HTML templates. +%htmllocale = (); +@htmltemplates = <../../templates/webpages/*/*_master.html>; +foreach $file (@htmltemplates) { + scanhtmlfile($file); +} + foreach $file (@progfiles) { %locale = (); @@ -72,7 +80,7 @@ foreach $file (@progfiles) { unlink 'missing'; foreach $text (keys %$missing) { - if ($locale{$text}) { + if ($locale{$text} || $htmllocale{$text}) { unless ($self{texts}{$text}) { $self{texts}{$text} = $missing->{$text}; } @@ -140,6 +148,10 @@ $self{subs} = { close FH; } +foreach $file (@htmltemplates) { + converthtmlfile($file); +} + # now print out all open FH, ">all" or die "$! : all"; @@ -379,3 +391,98 @@ sub scanmenu { } +sub scanhtmlfile { + local *IN; + + open(IN, $_[0]) || die; + + my $copying = 0; + my $text = ""; + while (my $line = ) { + chomp($line); + + while ("" ne $line) { + if (!$copying) { + if ($line =~ m||i) { + substr($line, 0, $+[0]) = ""; + $copying = 1; + + } else { + $line = ""; + } + + } else { + if ($line =~ m||i) { + $text .= $`; + substr($line, 0, $+[0]) = ""; + $copying = 0; + $alllocales{$text} = 1; + $htmllocale{$text} = 1; + $text = ""; + + } else { + $text .= $line; + $line = ""; + } + } + } + } + + close(IN); +} + +sub converthtmlfile { + local *IN; + local *OUT; + + open(IN, $_[0]) || die; + + my $langcode = (split("/", getcwd()))[-1]; + $_[0] =~ s/_master.html$/_${langcode}.html/; + + open(OUT, ">${_[0]}") || die; + + my $copying = 0; + my $text = ""; + while (my $line = ) { + chomp($line); + if ("" eq $line) { + print(OUT "\n"); + next; + } + + while ("" ne $line) { + if (!$copying) { + if ($line =~ m||i) { + print(OUT $`); + substr($line, 0, $+[0]) = ""; + $copying = 1; + print(OUT "\n") if ("" eq $line); + + } else { + print(OUT "${line}\n"); + $line = ""; + } + + } else { + if ($line =~ m||i) { + $text .= $`; + substr($line, 0, $+[0]) = ""; + $copying = 0; + $alllocales{$text} = 1; + $htmllocale{$text} = 1; + print(OUT $self{"texts"}{$text}); + print(OUT "\n") if ("" eq $line); + $text = ""; + + } else { + $text .= $line; + $line = ""; + } + } + } + } + + close(IN); + close(OUT); +} diff --git a/templates/webpages/generic/error.html b/templates/webpages/generic/error_master.html similarity index 65% rename from templates/webpages/generic/error.html rename to templates/webpages/generic/error_master.html index eb43ed772..2f121acb2 100644 --- a/templates/webpages/generic/error.html +++ b/templates/webpages/generic/error_master.html @@ -1,7 +1,7 @@ - + -- 2.20.1