当前位置: 首页>>代码示例>>Python>>正文


Python translator.register函数代码示例

本文整理汇总了Python中modeltranslation.translator.translator.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_content_model

def register_content_model(model_class, model_fields, register_file):
    model_class.register_templates(*FEINCMS_TEMPLATES['default'])

    ModelRestructuredContent = model_class.create_content_type(RestructuredContent, class_name='RestructuredContent')
    model_class.create_content_type(ImageContent, class_name='ImageContent')
    if register_file: model_class.create_content_type(FileContent, class_name='FileContent')

    register_model(model_class, model_fields)

    class ModelRestructuredContentTranslationOptions(TranslationOptions):
        fields = 'text',

    translator.register(ModelRestructuredContent, ModelRestructuredContentTranslationOptions)
开发者ID:alexgula,项目名称:django_sites,代码行数:13,代码来源:translations.py

示例2: register_content_model

def register_content_model(model_class, model_fields, translate=False, register_text=True, register_html=False):
    model_class.register_regions(('main', _("Main content area")),)
    ModelRestructuredContent = model_class.create_content_type(RestructuredContent, class_name=model_class.__name__ + 'Text') if register_text else None
    ModelHtmlContent = model_class.create_content_type(HtmlContent, class_name=model_class.__name__ + 'Html') if register_html else None
    ModelImageContent = model_class.create_content_type(ImageContent, class_name=model_class.__name__ + 'Image')

    if translate:
        register_model(model_class, model_fields)

        ModelRestructuredContent.feincms_item_editor_inline = TranslatedFeinCMSInline
        ModelHtmlContent.feincms_item_editor_inline = TranslatedFeinCMSInline
        ModelImageContent.feincms_item_editor_inline = TranslatedFeinCMSInline

        if register_text:
            class ModelRestructuredContentTranslationOptions(TranslationOptions):
                fields = 'text',

            translator.register(ModelRestructuredContent, ModelRestructuredContentTranslationOptions)

        if register_html:
            class ModelHtmlContentTranslationOptions(TranslationOptions):
                fields = 'text',

            translator.register(ModelHtmlContent, ModelHtmlContentTranslationOptions)

        class ModelImageContentTranslationOptions(TranslationOptions):
            fields = 'caption',

        translator.register(ModelImageContent, ModelImageContentTranslationOptions)
开发者ID:alexgula,项目名称:django_sites,代码行数:29,代码来源:translations.py

示例3: DashboardProjectTranslationOptions

from modeltranslation.translator import translator, TranslationOptions
from dashboard.models import Project as DashboardProject


#dashboard
class DashboardProjectTranslationOptions(TranslationOptions):
    fields = ('title',
              'description',
              )

translator.register(DashboardProject, DashboardProjectTranslationOptions)

开发者ID:geonition,项目名称:dashboard,代码行数:11,代码来源:translation.py

示例4: BlockTranslationOptions

from modeltranslation.translator import translator
from modeltranslation.translator import TranslationOptions


from .models import Block
from .models import SubBlock


class BlockTranslationOptions(TranslationOptions):
	fields = ['title', 'sub_title', 'text']

translator.register(Block, BlockTranslationOptions)


class SubBlockTranslationOptions(TranslationOptions):
	fields = ['title', 'sub_title', 'description']

translator.register(SubBlock, SubBlockTranslationOptions)
开发者ID:Baltrunas,项目名称:django-lp,代码行数:18,代码来源:translation.py

示例5: TranslatedMediaLibrary

from modeltranslation.translator import translator, TranslationOptions
from .models import MediaLibrary, MediaFile
from mezzanine.core.translation import TranslatedRichText

class TranslatedMediaLibrary(TranslatedRichText):
    field = ()

class TranslatedMediaFile(TranslationOptions):
    fields = ('description',)

translator.register(MediaLibrary, TranslatedMediaLibrary)
translator.register(MediaFile, TranslatedMediaFile)
开发者ID:nigelvanherwijnen,项目名称:nsawebdev,代码行数:12,代码来源:translation.py

示例6: ToolkitTranslation

"""
Translation registration for django modeltranslation
"""

from modeltranslation.translator import translator, TranslationOptions

from orb.toolkits import models


class ToolkitTranslation(TranslationOptions):
    fields = ('title', 'description')


translator.register(models.Toolkit, ToolkitTranslation)
开发者ID:wellfire,项目名称:django-orb,代码行数:14,代码来源:translation.py

示例7: ChunkOpts

# -*- coding: utf-8 -*-

from modeltranslation.translator import translator, TranslationOptions
from . import models


class ChunkOpts(TranslationOptions):
    fields = ('content', )


class ChunkGroupOpts(TranslationOptions):
    fields = ('content', )


class ChunkMediaOpts(TranslationOptions):
    fields = ('title', 'desc', 'media', )


translator.register(models.Media, ChunkMediaOpts)
translator.register(models.Group, ChunkGroupOpts)
translator.register(models.Chunk, ChunkOpts)
开发者ID:gotlium,项目名称:django-chunks2,代码行数:21,代码来源:translation.py

示例8: MetaTranslationOptions

from modeltranslation.translator import translator, TranslationOptions
from seoutils.models import Meta

class MetaTranslationOptions(TranslationOptions):
    fields = ('title', 'keywords', 'desc')
translator.register(Meta, MetaTranslationOptions)
开发者ID:devanasrikanth,项目名称:django-seoutils,代码行数:6,代码来源:translations.py

示例9: SectionTranslationOptions

from modeltranslation.translator import translator, TranslationOptions
from homepage.models import Section

class SectionTranslationOptions(TranslationOptions):
    fields = ('name', 'description',)

translator.register(Section, SectionTranslationOptions)
开发者ID:nikonikoniko,项目名称:syrianarchive,代码行数:7,代码来源:translation.py

示例10: TextTranslationOptions

from __future__ import unicode_literals

from django.utils.translation import ugettext as _
from django.utils.translation import get_language as _get_language
from modeltranslation.translator import translator, TranslationOptions
from modeltranslation import utils
from nsms.text.models import Text


class TextTranslationOptions(TranslationOptions):
    fields = ('text',)

translator.register(Text, TextTranslationOptions)

# need to translate something for django translations to kick in
_("Something to trigger localizations")


# monkey patch a version of get_language that isn't broken
def get_language():
    lang = _get_language()
    return lang

utils.get_language = get_language
开发者ID:daaray,项目名称:tracpro,代码行数:24,代码来源:translation.py

示例11: PageTransOps

from modeltranslation.translator import translator, TranslationOptions
from openbudget.apps.pages.models import Page


class PageTransOps(TranslationOptions):
    fields = ('title', 'content')


translator.register(Page, PageTransOps)
开发者ID:Dnile,项目名称:openmuni-budgets,代码行数:9,代码来源:translation.py

示例12: SubjectTranslationOptions

from modeltranslation.translator import translator, TranslationOptions
from contact_form.models import Subject


class SubjectTranslationOptions(TranslationOptions):
    fields = ('title', 'description')
    fallback_languages = {'default': ('en',)}

translator.register(Subject, SubjectTranslationOptions)
开发者ID:PixelActions,项目名称:django-crispy-contact-form,代码行数:9,代码来源:translation.py

示例13: MapTranslationOptions

# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################

from modeltranslation.translator import translator, TranslationOptions
from geonode.maps.models import Map, MapStory


class MapTranslationOptions(TranslationOptions):
    fields = (
        'title',
        'abstract',
        'purpose',
        'constraints_other',
        'supplemental_information',
        'data_quality_statement',
    )


translator.register(Map, MapTranslationOptions)
translator.register(MapStory)
开发者ID:lhcramer,项目名称:geonode,代码行数:30,代码来源:translation.py

示例14: GalleryTranslationOptions

from modeltranslation.translator import translator, TranslationOptions

from paintings.models import Gallery, Painting


class GalleryTranslationOptions(TranslationOptions):
	fields = ('title',)
	required_languages = ('ru', 'en',)


class PaintingTranslationOptions(TranslationOptions):
	fields = ('title',)
	required_languages = ('ru', 'en',)


translator.register(Gallery, GalleryTranslationOptions)
translator.register(Painting, PaintingTranslationOptions)
开发者ID:hombit,项目名称:olgart,代码行数:17,代码来源:translation.py

示例15: URLLinkTranslationOptions

# coding: utf-8
from modeltranslation.translator import translator, TranslationOptions
from models import URLLink


class URLLinkTranslationOptions(TranslationOptions):
    fields = ('title', 'description',)

translator.register(URLLink, URLLinkTranslationOptions)
开发者ID:socib,项目名称:django-socib-cms,代码行数:9,代码来源:translation.py


注:本文中的modeltranslation.translator.translator.register函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。