forked from st4lk/tornado_i18n_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
25 lines (18 loc) · 714 Bytes
/
app.py
File metadata and controls
25 lines (18 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import tornado.ioloop
import tornado.web
from babel.numbers import format_currency
class HomeHandler(tornado.web.RequestHandler):
def get(self):
_ = self.locale.translate
count = int(self.get_argument('count', 1))
format_usd = lambda p: format_currency(p, currency="USD",
locale=self.locale.code)
self.render("home.html", text=_("Hello, world!"), count=count,
format_usd=format_usd)
application = tornado.web.Application([
tornado.web.url(r"/", HomeHandler, name='home'),
])
if __name__ == "__main__":
tornado.locale.load_gettext_translations('locale', 'messages')
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()