Difference between revisions of "Routing and Template Cookbook: Translation system"
From Dreamwidth Notes
Foxfirefey (Talk | contribs) (Created page with "= Handlers = = Templates = In templates, the translation system can be accessed as a filter or a method. == Using translation strings == === As a filter: without extra arg...") |
(No difference)
|
Revision as of 18:37, 24 February 2013
Contents
Handlers
Templates
In templates, the translation system can be accessed as a filter or a method.
Using translation strings
As a filter: without extra arguments
[% '.createlayer.toplevel.label.coreversion' | ml %]
As a filter: with extra arguments
[% '.label' | ml(user = u.ljuser_display) %]
As a method: with extra arguments
[% dw.ml( '.createlayer.new', { 'name' => new_layer.name, 'id' => new_layer.s2lid } ) %]
Saving translations in a template variable
Sometimes it can be useful to save the results of a translation into a template variable that can be used later:
[%- confirm_msg = '.delete.text' | ml( type => layerinfo.laytype, name => "#$layerinfo.lid: $layerinfo.name") -%]
Including a template with a temporary ML scope change
[% dw.scoped_include('stats/site.tt'); %]