Hello, I need to display my Dancer app in at least 2 languages. Tried the i18n plugin, but i dont' need the full power of gettext/make text (plus, being a java guy -nobody is perfect- , i feel quite lost with it !). I found this method in PM : ---- In our app we take the language preferences of a user from his settings, cookie or guess it based on his browser headings or failing all, guess his language by his IP. In the head of .tt's we PROCESS the proper language template which holds the translations by key: The template inclusion is done via a: [%- PROCESS "locale/${user.lang}/lang.tt"; %] <http://www.perlmonks.org/?abspart=1;displaytype=displaycode;node_id=466456;part=1> The language files look like: [% lang.label.status = "Status"; .... lang.phrase.sure = "Are you sure"; %] and a tag is simply called using: [% lang.label.status %] --- It seems to perfectly suit my needs, but i can't make it work : [% lang.label.status %] would generate nothing. Has anyone tested a similar approach for i18n with Dancer ? Thanks. Patrick
Hello Patrick. 2011/6/13 patrick sanchez <pack.sanchez@gmail.com>:
The template inclusion is done via a: [%- PROCESS "locale/${user.lang}/lang.tt"; %]
The language files look like: [% lang.label.status = "Status"; .... lang.phrase.sure = "Are you sure"; %]
and a tag is simply called using: [% lang.label.status %]
I tried to test similar template using Dancer::Template::TemplateToolkit. It's works fine. to pass user.lang variable, I used template 'index', { user => { lang => 'en' }}; . What template engine do you use ? Dancer's default template engine Simple does not support [%- PROCESS "locale/${user.lang}/lang.tt"; %]. Regards. -- Takeshi OKURA
participants (2)
-
patrick sanchez -
Takeshi OKURA