【问题标题】:Anyone knows and good guide for using Localization for Tornado? [closed]任何人都知道使用 Tornado 本地化的良好指南吗? [关闭]
【发布时间】:2011-12-08 15:16:12
【问题描述】:

我正在彻底阅读 Tornado 文档并尝试学习 Tornado。

但是有些地方需要改一下,比如

{{ xsrf_form_html() }}

{% raw xsrf_form_html() %}

Cross-site request forgery protection

我在 wiki 中找到了该解决方案。

但我无法让 Localization 的示例工作

它不翻译任何东西。

任何人都知道使用 Tornado 本地化的良好指南吗?

【问题讨论】:

  • 请不要大喊大叫 :) 把问题放在问题标题中,这样会被注意到。
  • 您能否发布一个不起作用的完整示例(也可能与客户端请求有关——语言环境使用一些请求处理程序来计算翻译)?

标签: python localization internationalization tornado


【解决方案1】:

您可以尝试阅读http://tornado-babel.readthedocs.org/en/latest/index.html,其中解释了本地化过程。虽然大部分内容与标准 tornado.locale 模块相关,但tornado-babel 扩展了功能并将 babel 用于 l10n 和 i18n。

【讨论】:

    【解决方案2】:

    您是否调用了load_translations 方法?您的应用需要在start_server 之前调用它,例如:

    tornado.locale.load_translations(
        os.path.join(os.path.dirname(__file__), "translations"))
    

    您还需要带有翻译的 CSV 文件,in the correct format.

    【讨论】:

      【解决方案3】:

      tornado locale documentation 的工作链接。但在我看来,那里对 i18n 过程的描述很差。

      查看this article,它通过细节和示例解释了tornado 中的i18n 和i10n 进程。

      【讨论】:

        猜你喜欢
        • 2011-06-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-16
        • 2011-10-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多