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

<tfoot id='4jEel'></tfoot>
      • <bdo id='4jEel'></bdo><ul id='4jEel'></ul>

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

      1. 用于定义选择字段的元组列表中前导下划线的含义?

        时间:2023-07-23

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

                • <bdo id='D0J1g'></bdo><ul id='D0J1g'></ul>
                • <small id='D0J1g'></small><noframes id='D0J1g'>

                    <tbody id='D0J1g'></tbody>

                  本文介绍了用于定义选择字段的元组列表中前导下划线的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我见过一些这样定义选择字段的示例:

                  I've seen a few examples defining choice fields like so:

                  COUNTRIES = (
                      ('fr', _('France')),
                      ('de', _('Germany')),
                      ...
                  )
                  

                  (来源:http://code.djangoproject.com/ticket/5446另请参阅:http://djangosnippets.org/snippets/494/)

                  前导下划线是什么意思?为什么元组中的第二个值还要加上括号?

                  What is the meaning of the leading underscores? And why is the second value in the tuple even parenthesized?

                  推荐答案

                  前导下划线是国际化 (i18n) 机制使用的 ugettext 函数之一的常用函数别名.

                  The leading underscore is the commonly used function alias for the one of the ugettext functions used by the internationalization (i18n) mechanics.

                  这意味着当您运行 i18n 时,选择字段标签将被翻译成适当的最终用户语言(如果有翻译可用).

                  It means that when you have i18n running, the choicefield labels will be translated into the appropriate end-user language, if a translation is available.

                  在具有这种语法的文件的顶部,您应该看到(或者如果没有,您应该看到)如下内容:

                  At the top of a file that features this kind of syntax, you should see (or if not, you should have) something like:

                  from django.utils.translation import ugettext_lazy as _

                  查看此处的文档了解更多详情

                  这篇关于用于定义选择字段的元组列表中前导下划线的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:python中是否有任何内置的跨线程事件? 下一篇:如何在 Django 中获取当前语言?

                  相关文章

                  <small id='6L9Cn'></small><noframes id='6L9Cn'>

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

                    • <bdo id='6L9Cn'></bdo><ul id='6L9Cn'></ul>
                    <tfoot id='6L9Cn'></tfoot>
                    1. <legend id='6L9Cn'><style id='6L9Cn'><dir id='6L9Cn'><q id='6L9Cn'></q></dir></style></legend>