Skip to content

Commit

Permalink
fix i18n example
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Aug 26, 2013
1 parent f81bddf commit 954ef02
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
6 changes: 4 additions & 2 deletions deformdemo/__init__.py
Expand Up @@ -1249,7 +1249,7 @@ class Schema(colander.Schema):
form = deform.Form(schema, buttons=('submit',))
return self.render_form(form)

@view_config(renderer='templates/translated_form.pt', name='i18n')
@view_config(renderer='templates/form.pt', name='i18n')
@demonstrate('Internationalization')
def i18n(self):
minmax = {'min':1, 'max':10}
Expand All @@ -1275,7 +1275,9 @@ class Schema(colander.Schema):
buttons=[deform.Button('submit', _('Submit'))],
)

return self.render_form(form)
d = self.render_form(form)
d.update({'is_i18n': True, 'locale': locale_name})
return d

@view_config(renderer='templates/form.pt', name='hidden_field')
@demonstrate('Hidden Widget')
Expand Down
10 changes: 10 additions & 0 deletions deformdemo/templates/form.pt
@@ -1,5 +1,15 @@
<div metal:use-macro="view.macros['master']">
<div metal:fill-slot="main">
<div class="btn-group" tal:condition="is_i18n|False">
<a tal:attributes="class locale == 'en' and 'active btn btn-default' or 'btn btn-default'" href="${request.path_url}?_LOCALE_=en">English</a>
<a tal:attributes="class locale == 'nl' and 'active btn btn-default' or 'btn btn-default'" href="${request.path_url}?_LOCALE_=nl">Nederlands</a>
<a tal:attributes="class locale == 'ru' and 'active btn btn-default' or 'btn btn-default'" href="${request.path_url}?_LOCALE_=ru">Russian</a>
<a tal:attributes="class locale == 'es' and 'active btn btn-default' or 'btn btn-default'" href="${request.path_url}?_LOCALE_=es">Español</a>
<br />
<br />
</div>


<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Demo: ${title}</h3>
Expand Down
26 changes: 0 additions & 26 deletions deformdemo/templates/translated_form.pt

This file was deleted.

0 comments on commit 954ef02

Please sign in to comment.