2016-11-02 6 views
0

私はDjango Cmsを習得しようとしていますが、ここで私は立ち往生しています。 DjangoのCMSの公式ドキュメントの次のコード リンク内: - http://docs.django-cms.org/en/release-3.4.x/introduction/plugins.htmlこの行は何を示していますか: - Django CMSのPollPluginPublisherのmodule = _( "Polls")

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 

私はラインモジュール= _( "投票")の使用を取得することができません

答えて

0
from django.utils.translation import ugettext as _ 

Django I18N documentation

Djangoプロジェクトを翻訳可能にするには、 Pythonコードとテンプレートに最低限のフックを追加してください。これらのフックは翻訳ストリングと呼ばれます。彼らはDjangoに次のように伝えます:「このテキストはその言語で翻訳されていれば、エンドユーザの言語に翻訳する必要があります」翻訳可能な文字列をマークするのはあなたの責任です。システムはそれが知っている文字列のみを翻訳することができます。

...

機能ugettext()を使って翻訳文字列を指定します。これを短いエイリアス(_)としてインポートして、入力を省くことができます。

+0

ありがとうございましたIgnacio Vazquez-Abramsありがとうございますが、 "モジュール"変数がドキュメントに記載されていないので、なぜ使用されているのかわかります。 –

+0

いいえ、私はDjango CMSがどのように動作するのか分かりません。 –

+1

@ShashishekharHasabnisモジュール変数は、プラグインをグループ化する場所をCMSに指示します。たとえば、プラグインがたくさんあるアプリをお持ちの場合、これらのプラグインを特定の名前でグループ化する必要があります。モジュールが提供されていない場合、プラグインは「Generic」という名前でグループ化されます。 – Paulo

関連する問題