Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Commit

Permalink
supporting bottle >= 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
iocast committed Mar 13, 2014
1 parent 55f5a02 commit cf08bf7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
7 changes: 6 additions & 1 deletion bottle_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ def setup(self, app):
self._apps.append(app)
for app in self._apps:
app._ = lambda s: s
app.hooks.add('before_request', self.prepare)

if hasattr(app, 'add_hook'):
# attribute hooks was renamed to _hooks in version 0.12.x and add_hook method was introduced instead.
app.add_hook('before_request', self.prepare)
else:
app.hooks.add('before_request', self.prepare)

app.__class__.lang = property(fget=lambda x: self.get_lang(), fset=lambda x, value: self.set_lang(value))

Expand Down
15 changes: 8 additions & 7 deletions examples/views/en/hello.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<html>
<head>
<title>hello</title>
</head>
<body>
<p>hello <strong>{{lang()}}</strong></p>
<p>you used function <strong>{{function}}</strong></p>
</body>
<head>
<title>hello</title>
</head>
<body>
<p>hello <strong>{{lang()}}</strong></p>
<p>{{_('hello')}} {{_('world')}}</p>
<p>you used function <strong>{{function}}</strong></p>
</body>
</html>
15 changes: 8 additions & 7 deletions examples/views/fr/hello.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<html>
<head>
<title>bonjour</title>
</head>
<body>
<p>bonjour <strong>{{lang()}}</strong></p>
<p>vous avez utilisé fonction <strong>{{function}}</strong></p>
</body>
<head>
<title>bonjour</title>
</head>
<body>
<p>bonjour <strong>{{lang()}}</strong></p>
<p>{{_('hello')}} {{_('world')}}</p>
<p>vous avez utilisé fonction <strong>{{function}}</strong></p>
</body>
</html>
2 changes: 1 addition & 1 deletion setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name = 'bottle-i18n',
version = '0.1.4',
version = '0.1.5',
description = 'I18N integration for Bottle.',
long_description = long_description,
author = 'iocast',
Expand Down

0 comments on commit cf08bf7

Please sign in to comment.