Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Internationalization and Template::Toolkit

by Anonymous Monk
on Dec 01, 2004 at 16:16 UTC ( [id://411486]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks

I'm looking for the "best practices" for internationalizing a web application that uses Template Toolkit and haven't been able to find much. This page has one method, but it definitely looks like an atypical solution--developing an auto-extraction layer above the template.

thanks so much

  • Comment on Internationalization and Template::Toolkit

Replies are listed 'Best First'.
Re: Internationalization and Template::Toolkit
by dragonchild (Archbishop) on Dec 01, 2004 at 16:40 UTC
    Personally, I would definitely consider any solution Autrijus Tang puts up. He's kinda one of those people who not only has been around the block, but he helped build the block you're trying to go around.

    The nice thing about the solution in the page you mentioned is that it drops in and, other than the localizable text, the website doesn't change. This is a big improvement over other schemes I've seen, which generally involve post-processing the templates with the static text, then praying the dynamic text from the database is the right language.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Plus, it's got a toolchain. GNU gettext msggen and friends work with it, so you can extract (and update) localizable strings, and have your translators use whatever tools they alrady like for dealing with PO files.

      (One note: if you define a gettext()/_()-like function for use in code, don't name it _ because there's a funky problem with the meaning of it. Use __ (double underscore); Autrijus' version of gettext is patched to handle it.)

Re: Internationalization and Template::Toolkit
by matthewb (Curate) on Dec 01, 2004 at 22:22 UTC

    I've done this.

    When putting together a solution, I found this presentation useful.

    I used Class::DBI to model `resources' within my web application wherein the actual translated text (where required) was located in a linked table/sub-class.

    Use content-negotiation, as mentioned in the article you reference, backed up with an option to override. You'll want a look at HTTP::Negotiate now if you haven't seen it already. Maybe also one of the session modules for retaining user preferences.

    You'd also be well advised to get your web-designer to consider how their pixel-perfect navigation is going to look in other languages ;)

    MB

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found