Le 18 janv. 06 à 14:10, Simon Wistow a écrit :
On Thu, Jan 12, 2006 at 03:44:55PM +0000, me said:
Now all I need to do is change the translate() function to actually
translate using gettext and then somehow get the current language
from a
Template::Plugin::Translate, presumably by dicking around with
$context;
I now have this working.
Given a standard Locale::MakeText lexicon called (for the purposes of
illustration 'MyTranslation') with the item _GREETING_ set in it then
[%- USE Localisation('MyTranslation') -%]
[%- SET foo = "_GREETING_" -%]
[% foo %]
[% "_GREETING_" %]
prints
Hello
Hello
and changing the first line to
[%- USE Localisation('MyTranslation','fr') -%]
prints
Bonjour
Bonjour
There's still a couple of issues to be sorted out and I'm not
convinced
that Locale::MakeText is the right il8n module to use for various
reasons but I think this could be really useful for doing multi
language
websites.
Sometimes it's preferrable to embed translations in the template
itself, for
various reasons, so shameless plug for Template::Multilingual which
lets you
write this:
<t><fr>Bonjour !</fr><en>Hello!</en></t>
The perl code provides the current language before calling process(),
or even
as a template variable.
Just an alternative, the MakeText method certainly has its own merits.
--
Eric Cholet
Will the highways on the Internet become more few? -- G.W. Bush,
Concord, N.H., Jan. 29, 2000
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates