<tfoot id='Zl8OM'></tfoot>

    <legend id='Zl8OM'><style id='Zl8OM'><dir id='Zl8OM'><q id='Zl8OM'></q></dir></style></legend>

      <small id='Zl8OM'></small><noframes id='Zl8OM'>

      <i id='Zl8OM'><tr id='Zl8OM'><dt id='Zl8OM'><q id='Zl8OM'><span id='Zl8OM'><b id='Zl8OM'><form id='Zl8OM'><ins id='Zl8OM'></ins><ul id='Zl8OM'></ul><sub id='Zl8OM'></sub></form><legend id='Zl8OM'></legend><bdo id='Zl8OM'><pre id='Zl8OM'><center id='Zl8OM'></center></pre></bdo></b><th id='Zl8OM'></th></span></q></dt></tr></i><div id='Zl8OM'><tfoot id='Zl8OM'></tfoot><dl id='Zl8OM'><fieldset id='Zl8OM'></fieldset></dl></div>

        • <bdo id='Zl8OM'></bdo><ul id='Zl8OM'></ul>
      1. ugettext 和 ugettext_lazy

        时间:2023-07-23
        • <bdo id='Ph4d9'></bdo><ul id='Ph4d9'></ul>

        • <tfoot id='Ph4d9'></tfoot>

          <small id='Ph4d9'></small><noframes id='Ph4d9'>

          • <legend id='Ph4d9'><style id='Ph4d9'><dir id='Ph4d9'><q id='Ph4d9'></q></dir></style></legend>
          • <i id='Ph4d9'><tr id='Ph4d9'><dt id='Ph4d9'><q id='Ph4d9'><span id='Ph4d9'><b id='Ph4d9'><form id='Ph4d9'><ins id='Ph4d9'></ins><ul id='Ph4d9'></ul><sub id='Ph4d9'></sub></form><legend id='Ph4d9'></legend><bdo id='Ph4d9'><pre id='Ph4d9'><center id='Ph4d9'></center></pre></bdo></b><th id='Ph4d9'></th></span></q></dt></tr></i><div id='Ph4d9'><tfoot id='Ph4d9'></tfoot><dl id='Ph4d9'><fieldset id='Ph4d9'></fieldset></dl></div>
                  <tbody id='Ph4d9'></tbody>

                  本文介绍了ugettext 和 ugettext_lazy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您能解释一下 ugettextugettext_lazy 之间的主要区别吗?

                  Could you explain what principal difference between ugettext and ugettext_lazy?

                  当我尝试时

                  return HttpResponse(ugettext_lazy("Hello"))
                  

                  我什么也没看到,但是

                  return HttpResponse(ugettext("Hello"))
                  

                  正在工作.

                  为什么?

                  推荐答案

                  ugettext 用于加载字符串的翻译现在.ugettext_lazy 返回一个最终可以变成字符串的对象.如果在设置正确的语言环境之前评估了 ugettext_lazy 调用,则需要这样做.

                  ugettext is used to load a translation of a string right now. ugettext_lazy returns an object that can eventually be turned into a string. You need that if the ugettext_lazy call is evaluated before the proper locale has been set.

                  ugettext_lazy 可用于使用 Unicode 对象的地方.仔细检查您的 HTML 输出,它可能如下所示:

                  ugettext_lazy can be used where you use a Unicode object. Double-check your HTML output, it might look like this:

                  <django.utils.functional...>
                  

                  并且浏览器将其全部忽略为无法识别的标签.

                  and the browser is ignoring it all as an unrecognized tag.

                  在这种情况下,您不需要惰性翻译,因为您会立即使用该字符串.如果您出于某种原因确实想继续使用 ugettext_lazy,请尝试以下操作:

                  You don't need a lazy translation in this case, because you are immediately using the string. If you really want to continue with ugettext_lazy for some reason, try this:

                  return HttpResponse(ugettext_lazy("Hello").encode('utf-8'))
                  

                  有关详细信息,请参阅文档.

                  See the docs for more information.

                  这篇关于ugettext 和 ugettext_lazy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 python 中处理国际日期 下一篇:Django 模型翻译查询回退

                  相关文章

                    <bdo id='4SCbk'></bdo><ul id='4SCbk'></ul>
                1. <legend id='4SCbk'><style id='4SCbk'><dir id='4SCbk'><q id='4SCbk'></q></dir></style></legend>

                  1. <i id='4SCbk'><tr id='4SCbk'><dt id='4SCbk'><q id='4SCbk'><span id='4SCbk'><b id='4SCbk'><form id='4SCbk'><ins id='4SCbk'></ins><ul id='4SCbk'></ul><sub id='4SCbk'></sub></form><legend id='4SCbk'></legend><bdo id='4SCbk'><pre id='4SCbk'><center id='4SCbk'></center></pre></bdo></b><th id='4SCbk'></th></span></q></dt></tr></i><div id='4SCbk'><tfoot id='4SCbk'></tfoot><dl id='4SCbk'><fieldset id='4SCbk'></fieldset></dl></div>
                    <tfoot id='4SCbk'></tfoot>

                      <small id='4SCbk'></small><noframes id='4SCbk'>