Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Multilingual website with HTML::Template and Class::PhraseBook

by boboson (Monk)
on Mar 07, 2006 at 15:38 UTC ( [id://534950]=perlquestion: print w/replies, xml ) Need Help??

boboson has asked for the wisdom of the Perl Monks concerning the following question:

I am using Class::PhraseBook and HTML::Template to create a multilingual website (or I am trying to...). However, there will be alot of phrases and I don't want to substitute every singel one of them into a HTML::Template variable such as.
$tmpl->param(testvar => "hello");
Is there any easier way to accomplish this task?
Can I send the Class::PhraseBook object directly to HTML::Template, or is there any other module where this can be done?

Replies are listed 'Best First'.
Re: Multilingual website with HTML::Template and Class::PhraseBook
by InfiniteSilence (Curate) on Mar 07, 2006 at 17:00 UTC
    HTML::Template internally represents data as hashes of arrays that have hashes in them. This is an example from the perldoc:
    $template->param(EMPLOYEE_INFO => [ { name => 'Sam', job => 'pr +ogrammer' }, { name => 'Steve', job => ' +soda jerk' }, ] );
    If you read in your data using XML::Simple it will be represented in almost the exact same structure (depending upon the parameters you set in XML::Simple).

    So the answer may be to just use XML::Simple rather than Class::PhraseBook to implement your solution.

    Celebrate Intellectual Diversity

Re: Multilingual website with HTML::Template and Class::PhraseBook
by kutsu (Priest) on Mar 07, 2006 at 16:51 UTC

    I don't know about Class::PhraseBook but if you use Template::Toolkit you can send the data as a hash and access it that way.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://534950]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found