Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

HTML::Template I18N/L10N/gettext

by skazat (Chaplain)
on Sep 18, 2015 at 22:15 UTC ( [id://1142468]=perlquestion: print w/replies, xml ) Need Help??

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

I'm working on a webapp project that has many dozens of HTML::Template templates for all of its views. We'd like to add I18N/L10N support, so that say: we can ship versions of the web app in English, French, German - language would be a preference you could set up during the initial installation.

Right now, the base language is English. From my research, the best way to go about this is using gettext in some way, of some flavor.

All the examples I see for Perl apps are for strings in the Perl code itself, and not in any sort of template files. I'm unclear what the workflow is, to most easily make this work well.

Some ideas:

For template files, the first thing seems to be, to tag the strings in your templates that should be translated in some way that they can later be parsed out - for example: wrapping all your strings in brackets:

[This string should be translated!]

Then, run a script that finds these strings, for example, this weird find:

http://rp-www.cs.usyd.edu.au/~dcutting/photos/htmltmpl-1.22/tmpl-xgettext.pl

(I couldn't find this script in the current HTML::Template distribution.)

Once these strings are found, I'm then really fuzzy at what the workflow should be.

Do I then have a script, that makes alternative versions of my template files (one version for English, one for French, one for German), by replacing the base English strings with the French and German versions? Is there a place where this workflow is documented?

Replies are listed 'Best First'.
Re: HTML::Template I18N/L10N/gettext
by Anonymous Monk on Sep 18, 2015 at 22:59 UTC

    See HTML::Template::Compiled::Plugin::I18N and Template::Plugin::Filter::I18N

    Basically, you create a master template, where you designate whats part of your dictionary/catalog

    Then use poedit to add translations/catalogs

    You could generate a specific template for each language but that probably doesn't play well with catalog tools

    You should have the translator proofread the stuff in context ie final form

      HTML::Template::Compiled::Plugin::I18N doesn't look straightforward at all, and would require me to use a different templating language (with yes, the same syntax, but I'm sure to run into problems).

      Template::Plugin::Filter::I18N is a broken link. Is it this?. If so, there's no documentation.

      Catalog tools? Do you mean for indexing (search, etc?)

      -skazat

        HTML::Template::Compiled::Plugin::I18N doesn't look straightforward at all, and would require me to use a different templating language (with yes, the same syntax, but I'm sure to run into problems).

        Right, link is to give perspective

        Template::Plugin::Filter::I18N is a broken link. Is it this?. If so, there's no documentation.

        Well, thats a metacpan bug it seems. Template::Plugin::Filter::I18N works and yes the docs are succinct :)

        I for got to give Catalyst::Plugin::I18N::Manual its more detailed much wider perspective, it links gettext/catalog tools like poedit

Re: HTML::Template I18N/L10N/gettext
by Anonymous Monk on Oct 01, 2015 at 14:27 UTC
    if you need a solution to translate a web app using gettext, try the software localization tool POEditor(.com).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-23 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found