LanX has asked for the wisdom of the Perl Monks concerning the following question:
I have to improvise a multi-language CGI (sorry) without template system with in Perl embedded HTML (sorry)
I "invented" my own pure Perl language templating in the following code and would be interested in feedback and suggestions.
use strict; use warnings; use Data::Dump; my $language ='de'; # cgi-par +am # $language ='fr'; # cgi-para +m my %allowed_language = map { ($_=>1) } qw/en de/ ; unless ( $allowed_language{$language} ) { my $default='en'; warn "Unknown language code '$language', falling back to '$default' +"; $language = $default; } my $ht = <<"__HTML__"; <title>@{[ text( en=>"English", de=>"Deutsch" ) ]}</title> __HTML__ print $ht; sub text { my %texts =@_; return $texts{$language}; }
Most likely reinventing the wheel ...
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RFC: improvising multi language HTML
by shmem (Chancellor) on Aug 12, 2015 at 19:57 UTC | |
by LanX (Saint) on Aug 13, 2015 at 10:29 UTC | |
|
Re: RFC: improvising multi language HTML (gettext)
by Anonymous Monk on Aug 11, 2015 at 23:47 UTC | |
by LanX (Saint) on Aug 12, 2015 at 11:12 UTC |