文档:http://www.tornadoweb.org/en/stable/locale.html?highlight=translate#tornado.locale.Locale.translate
我在某个html文件中看到了一个提交按钮:<input type="submit" value="{{ _("Post") }}"/>
并且混淆了为什么作者设置了value={{ _("Post") }}
而不仅仅是value="Post"
。翻译有什么意义?
答案 0 :(得分:1)
在Tornado模板中,_
只是调用已配置区域设置的translate
方法的既定方法,并且可在任何模板中全局使用(请参阅Tornado's templates translate function '_', where does it come from?)。
tornado.locale.Locale.translate是一个抽象方法,如果直接调用则抛出NotImplentedError
。它在GettextLocale或CSVLocale类中实施。