Re: Multi Language
"Matias Alejo Garcia" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.html-template |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I am working in I18N of a price comparisson site these days.
Our strategy is:
- We use: Locale::gettext (is the simplest locale function, enoght for our
need, and very stable, even using threaded apache/mod_perl).
- All texts in the PERL code are given using gettext. These texts are
translated on the fly, using current site localte setup. e.g:
$template->param('pay_type', _($pay_type[$i]);
where _() is a wrapper of gettext()
- All texts in HTML::Template's templates are given using gettext. This are
precompiled. For example we have:
welcome.tmpl <<EOF
<h1> _'Hello there' <tmpl_var username> </h1>
_'Your store balance is %s'_<tmpl_var balance>
EOF
That is the true template. To use it in a site we precompile it, for
exemple:
./precompile_templates.pl en_US.UTF8
and we get:
<h1> Hello there <tmpl_var username> </h1>
Your store's balance is <tmpl_var balance>
or
./precompile_templates.pl es_AR.UTF8
and we get:
<h1> Hola <tmpl_var username> </h1>
Disponés de <tmpl_var balance> en tu cuenta
We precompile all templates, for all locales, in different directories. By
doing that we don't have an extra overhead for I18N.
-- All the texts of the sites are in one .po file (actuale, one for each
locale), which we edit in poedit (WIN/Linux) o gvim.
-- When working on the site layout, in order not to recompile every site
after each simple modification (while developing) where use the original
templates (not gettext'ed yet).
Finally, let me add that we use mysql with UTF8 collation and 'use utf8'
pragma in perl.
I hope this help,
matías
On 8/23/06, Mathew Robertson <[email protected]> wrote:
>
> Hi there,
>
> There are a number of ways to implement multi-language support,
> depending on your personal preference.
>
>
> Dynamic content sometimes shouldn't be translated, other times it
> should be translated. eg: if you have the car company "Nissan", in
> most languages you dont translate, but in Japanese you do. The
> exact circumstances of when to translate, will depend on your
> application domain and the linguistic rules of the end-users' language.
>
> One choice you will need to make is how frequently you will allow
> updates to your translated strings. This will determine whether you
> need something like a database lookup, or a simple file containing a
> relatively infrequently changing set of translations.
>
>
> Static content is often a bit easier:
>
> - translate the templates (containing the static text) into the
> language of choice -> output the HTML content from the appropriate
> template file.
>
> - Use H::T::E to callback into a registered 'translate(..)' function
> so that you can lookup translations.
>
> - Use a version of H::T which has plugin support for more TMPL_xxx
> tags, so that you can lookup translations.
>
> The implementation that you use will depends on whether you have
> access to a database to store translations in; and the "page render
> time" of your application. Eg: dynamic lookup of translations will
> incur a small performance hit when generating the HTML page; using
> H::T::E can be a big performance hit.
>
>
> There are a few good Perl modules which may help you implement your
> translation mechanism:
>
> - Locale::Maketext
> - pros: fast
> : powerful per-language capabilities
> - cons: requires programmer input to implement language rules
>
> - Locale::MakePhrase **
> - pros: powerful meta-language for implementing language rules
> : can use database, file or directory based backing stores
> - cons: slow - rules need to be evaluated
>
> ** Note: I wrote this package based on Locale::Maketext, so I may be
> a little biased.
>
>
> Example: Our application outputs 6 languages (English, Italian,
> Spanish, Korean, Japanese, Chinese) as well as handling dialects
> (en_us vs. en_au vs en), using one set of templates that dynamically
> lookup translations from a database.
>
> If you need further info, let me know.
>
> Mathew
>
> PS. I am working currently working on (at a slow rate...) a module
> which joins H::T with Locale::MakePhrase, so as to simplify some of
> the user-space code for handling the language-translation TMPL_xxx tags.
>
>
> Di Domenico, Michael wrote:
> > Does anyone have any recommendations on the best way to implement multi
> > language support using HTML::Template? I saw a few posts from a few
> > years ago on the subject in the mailing list archives, but otherwise I
> > can't find much information on the web. Unless I'm looking in the wrong
> > places.
> >
> >
> >
> > Thanks
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> -------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services,
> security?
> > Get stuff done quickly with pre-integrated technology to make your job
> easier
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Html-template-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/html-template-users
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
>
--
Matías Alejo García
NITS Argentina
| http://www.nits.com.ar
UADE
| Profesor Adjunto
| Departamento de Informática
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users