本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例8: MetaTranslationOptions
from modeltranslation.translator import translator, TranslationOptions
from seoutils.models import Meta
class MetaTranslationOptions(TranslationOptions):
fields = ('title', 'keywords', 'desc')
translator.register(Meta, MetaTranslationOptions)
示例9: SectionTranslationOptions
from modeltranslation.translator import translator, TranslationOptions
from homepage.models import Section
class SectionTranslationOptions(TranslationOptions):
fields = ('name', 'description',)
translator.register(Section, SectionTranslationOptions)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)