此行表示什么:- Django CMS PollPluginPublisher 中的 module = _("Polls")
what does this line indicate:- module = _("Polls") in Django CMS PollPluginPublisher
我正在尝试学习 Django Cms,但这是我遇到的问题。在Django CMS官方文档的以下代码中
Link:-http://docs.django-cms.org/en/release-3.4.x/introduction/plugins.html
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from polls_cms_integration.models import PollPluginModel
from django.utils.translation import ugettext as _
class PollPluginPublisher(CMSPluginBase):
model = PollPluginModel # model where plugin data are saved
module = _("Polls")
name = _("Poll Plugin") # name of the plugin in the interface
render_template = "polls_cms_integration/poll_plugin.html"
def render(self, context, instance, placeholder):
context.update({'instance': instance})
return context
plugin_pool.register_plugin(PollPluginPublisher) # register the plugin
我无法使用线路模块 = _("Polls")
from django.utils.translation import ugettext as _
In order to make a Django project translatable, you have to add a minimal number of hooks to your Python code and templates. These hooks are called translation strings. They tell Django: “This text should be translated into the end user’s language, if a translation for this text is available in that language.” It’s your responsibility to mark translatable strings; the system can only translate strings it knows about.
...
Specify a translation string by using the function ugettext()
. It’s convention to import this as a shorter alias, _
, to save typing.
我正在尝试学习 Django Cms,但这是我遇到的问题。在Django CMS官方文档的以下代码中 Link:-http://docs.django-cms.org/en/release-3.4.x/introduction/plugins.html
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from polls_cms_integration.models import PollPluginModel
from django.utils.translation import ugettext as _
class PollPluginPublisher(CMSPluginBase):
model = PollPluginModel # model where plugin data are saved
module = _("Polls")
name = _("Poll Plugin") # name of the plugin in the interface
render_template = "polls_cms_integration/poll_plugin.html"
def render(self, context, instance, placeholder):
context.update({'instance': instance})
return context
plugin_pool.register_plugin(PollPluginPublisher) # register the plugin
我无法使用线路模块 = _("Polls")
from django.utils.translation import ugettext as _
In order to make a Django project translatable, you have to add a minimal number of hooks to your Python code and templates. These hooks are called translation strings. They tell Django: “This text should be translated into the end user’s language, if a translation for this text is available in that language.” It’s your responsibility to mark translatable strings; the system can only translate strings it knows about.
...
Specify a translation string by using the function
ugettext()
. It’s convention to import this as a shorter alias,_
, to save typing.