Tornado - Locale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.locale | |
import tornado.web | |
import os | |
class ENHandler(tornado.web.RequestHandler): | |
def get(self): | |
tornado.locale.set_default_locale('us_US') | |
self.render("locale_template.html") | |
class FRHandler(tornado.web.RequestHandler): | |
def get(self): | |
tornado.locale.set_default_locale('fr_FR') | |
self.render("locale_template.html") | |
class DEHandler(tornado.web.RequestHandler): | |
def get(self): | |
tornado.locale.set_default_locale('de_DE') | |
self.render("locale_template.html") | |
application = tornado.web.Application([ | |
(r"/fr/", FRHandler), | |
(r"/en/", ENHandler), | |
(r"/de/", DEHandler), | |
],debug=True) | |
if __name__ == '__main__': | |
translationsPath = os.path.join("/home/ubuntu/tornado-2.2", "translations") | |
application.listen(8888) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! What does locale_template.html look like? Does this translate phrases in place, or do I have to pass strings to be translated to the template separately? Thanks!