iocast / bottle-i18n Goto Github PK
View Code? Open in Web Editor NEWi18n support for bottlepy
License: MIT License
i18n support for bottlepy
License: MIT License
When running examples/basic.py, got such error information as below.
I use bottle 0.12.4. Seems that "app.add_hook(name, func)" should be used instead.
http://bottlepy.org/docs/dev/api.html#bottle.Bottle.add_hook
Traceback (most recent call last):
File "basic.py", line 43, in <module>
bottle.run(app=get(), host='0.0.0.0', port='8000', quiet=False, reloader=True, debug=True)
File "basic.py", line 39, in get
return I18NMiddleware(app, I18NPlugin(domain='messages', default='en', locale_dir='./locale'))
File "/usr/local/lib/python2.7/site-packages/bottle_i18n.py", line 50, in __init__
self.app.install(i18n)
File "/usr/local/lib/python2.7/site-packages/bottle.py", line 713, in install
if hasattr(plugin, 'setup'): plugin.setup(self)
File "/usr/local/lib/python2.7/site-packages/bottle_i18n.py", line 115, in setup
app.hooks.add('before_request', self.prepare)
AttributeError: 'Bottle' object has no attribute 'hooks'
https://pypi.python.org/pypi/bottle-i18n/0.1.5 shows this:
That is not correct Python indentation.
(Possibly you're mixing tabs and spaces, and PyPI renders the tabs too narrowly?)
Please correct me if I'm wrong, but as far as I can see the following code in I18NMiddleware is not thread-safe:
self.app.lang = locale
...
self.app.lang = i18n._default
If the Bottle app is used with a multi-threaded server (e.g. paste or uwsgi), different requests will be trying to set attributes on the same application object concurrently, leading to wrong language being rendered for some of the users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.