1<%page args="x, y=_('Page arg 1'), z=_('Page arg 2')"/> 2<%! 3import random 4def gettext(message): return message 5_ = gettext 6def ungettext(s, p, c): 7 if c == 1: 8 return s 9 return p 10top = gettext('Begin') 11%> 12<% 13 # TRANSLATOR: Hi there! 14 hithere = _('Hi there!') 15 16 # TRANSLATOR: you should not be seeing this in the .po 17 rows = [[v for v in range(0,10)] for row in range(0,10)] 18 19 hello = _('Hello') 20%> 21<div id="header"> 22 ${_('Welcome')} 23</div> 24<table> 25 % for row in (hithere, hello, _('Yo')): 26 ${makerow(row)} 27 % endfor 28 ${makerow(count=2)} 29</table> 30 31 32<div id="main"> 33 34## TRANSLATOR: Ensure so and 35## so, thanks 36 ${_('The')} fuzzy ${ungettext('bunny', 'bunnies', random.randint(1, 2))} 37</div> 38 39<div id="footer"> 40 ## TRANSLATOR: Good bye 41 ${_('Goodbye')} 42</div> 43 44<%def name="makerow(row=_('Babel'), count=1)"> 45 <!-- ${ungettext('hella', 'hellas', count)} --> 46 % for i in range(count): 47 <tr> 48 % for name in row: 49 <td>${name}</td>\ 50 % endfor 51 </tr> 52 % endfor 53</%def> 54 55<%def name="comment()"> 56 <!-- ${caller.body()} --> 57</%def> 58 59<%block name="foo"> 60 ## TRANSLATOR: Ensure so and 61 ## so, thanks 62 ${_('The')} fuzzy ${ungettext('bunny', 'bunnies', random.randint(1, 2))} 63</%block> 64 65<%call expr="comment"> 66 P.S. 67 ## TRANSLATOR: HTML comment 68 ${_('Goodbye, really!')} 69</%call> 70 71<!-- ${_('P.S. byebye')} --> 72 73<div id="end"> 74 <a href="#top"> 75 ## TRANSLATOR: you won't see this either 76 77 ${_('Top')} 78 </a> 79</div> 80 81<%def name="panel()"> 82 83${_(u'foo')} <%self:block_tpl title="#123", name="_('baz')" value="${_('hoho')}" something="hi'there" somethingelse='hi"there'> 84 85${_(u'bar')} 86 87</%self:block_tpl> 88 89</%def> 90 91## TRANSLATOR: <p> tag is ok? 92<p>${_("Inside a p tag")}</p> 93 94## TRANSLATOR: also this 95<p>${even_with_other_code_first()} - ${_("Later in a p tag")}</p> 96 97## TRANSLATOR: we still ignore comments too far from the string 98 99<p>${_("No action at a distance.")}</p> 100 101## TRANSLATOR: nothing to extract from these blocks 102 103% if 1==1: 104<p>One is one!</p> 105% elif 1==2: 106<p>One is two!</p> 107% else: 108<p>How much is one?</p> 109% endif 110 111% for i in range(10): 112<p>${i} squared is ${i*i}</p> 113% else: 114<p>Done with squares!</p> 115% endfor 116 117% while random.randint(1,6) != 6: 118<p>Not 6!</p> 119% endwhile 120 121## TRANSLATOR: for now, try/except blocks are ignored 122 123% try: 124<% 1/0 %> 125% except: 126<p>Failed!</p> 127% endtry 128 129## TRANSLATOR: this should not cause a parse error 130${ 1 } 131