1
2
3
4
5
6
7
8
9
10
my %lang;
$lang{"status"}{"de"} = "Status";
$lang{"filter_on"}{"de"} = "eingeschaltet";
$lang{"filter_off"}{"de"} = "ausgeschaltet";
$lang{"ok"}{"de"} = "OK";
$lang{"status"}{"en"} = "State";
$lang{"filter_on"}{"en"} = "on";
$lang{"filter_off"}{"en"} = "off";
$lang{"ok"}{"en"} = "OK";
1
2
3
4
5
6
7
use Data::Dumper;
print Dumper \%lang;
for (keys %lang) {
print "Add $_ with $lang{$_}{$sesslang} for Sessionlang $sesslang <br>";
push @{$test->{"lang_$_"}}, join(".", $lang{$_}->{$sesslang} ) ;
}
ARRAY(0x30bed50)
Guest TinoCode: (dl )join(".", $lang{$_}->{$sesslang} )
join(".", @{ $lang{$_}->{$sesslang} })
1 2 3 4
for (keys %lang) { print "Add $_ with $lang{$_}{$sesslang} for Sessionlang $sesslang <br>"; push @{$test->{"lang_$_"}}, join(".", @{ $lang{$_}->{$sesslang} }) ; }
QuoteCan't use string ("OK") as an ARRAY ref while "strict refs" in use ...
join(".", @{ $lang{$_}->{$sesslang} })
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
my %lang; $lang{"status"}{"de"} = "Status"; $lang{"filter_on"}{"de"} = "eingeschaltet"; $lang{"filter_off"}{"de"} = "ausgeschaltet"; $lang{"ok"}{"de"} = "OK"; $lang{"status"}{"en"} = "State"; $lang{"filter_on"}{"en"} = "on"; $lang{"filter_off"}{"en"} = "off"; $lang{"ok"}{"en"} = "OK"; my %test; my $sesslang = 'de'; for my $keyword ( keys %lang ) { print "Add $keyword with $lang{$keyword}{$sesslang} for Sessionlang $sesslang <br>\n"; push @{ $test{"lang_$sesslang"} }, $lang{$keyword}{$sesslang}; } print join '.', @{ $test{lang_de} }; print "<br>\n";
1
2
3
4
5
Add ok with OK for Sessionlang de <br>
Add filter_off with ausgeschaltet for Sessionlang de <br>
Add status with Status for Sessionlang de <br>
Add filter_on with eingeschaltet for Sessionlang de <br>
OK.ausgeschaltet.Status.eingeschaltet<br>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
my %vars = {};
my $tt = Template->new({
ABSOLUTE => 1,
VARIABLES => {
stylesheet => $Color,
title => $Title,
loginid => $username,
userid => $userid,
lang => $sesslang,
},
});
# Sprache einbinden
for (keys %lang) {
#print "Add $_ with $lang{$_}{$sesslang} for Sessionlang $sesslang <br>";
$vars{"lang_$_"} = $lang{$_}->{$sesslang};
}
[...]
$tt->process($Template, \%vars ) || die "Template process failed: ", $tt->error(), "\n";