<%page args="x, y=_('Page arg 1'), z=_('Page arg 2')"/> <%! import random def gettext(message): return message _ = gettext def ungettext(s, p, c): if c == 1: return s return p top = gettext('Begin') %> <% # TRANSLATOR: Hi there! hithere = _('Hi there!') # TRANSLATOR: you should not be seeing this in the .po rows = [[v for v in range(0,10)] for row in range(0,10)] hello = _('Hello') %> % for row in (hithere, hello, _('Yo')): ${makerow(row)} % endfor ${makerow(count=2)}
## TRANSLATOR: Ensure so and ## so, thanks ${_('The')} fuzzy ${ungettext('bunny', 'bunnies', random.randint(1, 2))}
<%def name="makerow(row=_('Babel'), count=1)"> % for i in range(count): % for name in row: ${name}\ % endfor % endfor <%def name="comment()"> <%block name="foo"> ## TRANSLATOR: Ensure so and ## so, thanks ${_('The')} fuzzy ${ungettext('bunny', 'bunnies', random.randint(1, 2))} <%call expr="comment"> P.S. ## TRANSLATOR: HTML comment ${_('Goodbye, really!')}
## TRANSLATOR: you won't see this either ${_('Top')}
<%def name="panel()"> ${_(u'foo')} <%self:block_tpl title="#123", name="_('baz')" value="${_('hoho')}" something="hi'there" somethingelse='hi"there'> ${_(u'bar')} ## TRANSLATOR:

tag is ok?

${_("Inside a p tag")}

## TRANSLATOR: also this

${even_with_other_code_first()} - ${_("Later in a p tag")}

## TRANSLATOR: we still ignore comments too far from the string

${_("No action at a distance.")}

## TRANSLATOR: nothing to extract from these blocks % if 1==1:

One is one!

% elif 1==2:

One is two!

% else:

How much is one?

% endif % for i in range(10):

${i} squared is ${i*i}

% else:

Done with squares!

% endfor % while random.randint(1,6) != 6:

Not 6!

% endwhile ## TRANSLATOR: for now, try/except blocks are ignored % try: <% 1/0 %> % except:

Failed!

% endtry ## TRANSLATOR: this should not cause a parse error ${ 1 }