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


Python helper.get_translation函数代码示例

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


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

示例1: reset_translation

def reset_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if obj.do_reset(request):
        messages.info(request, _('All repositories have been reset.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例2: update_translation

def update_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if obj.do_update(request):
        messages.info(request, _('All repositories were updated.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例3: update_lock

def update_lock(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if not obj.is_user_locked(request):
        obj.update_lock_time()

    return HttpResponse('ok')
开发者ID:camilonova,项目名称:weblate,代码行数:7,代码来源:lock.py

示例4: reset_translation

def reset_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if obj.do_reset(request):
        messages.info(request, _('All repositories have been reset.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例5: commit_translation

def commit_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    obj.commit_pending(request)

    messages.info(request, _('All pending translations were committed.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例6: update_translation

def update_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if obj.do_update(request):
        messages.info(request, _('All repositories were updated.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例7: commit_translation

def commit_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    obj.commit_pending(request)

    messages.info(request, _('All pending translations were committed.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例8: auto_translation

def auto_translation(request, project, subproject, lang):
    translation = get_translation(request, project, subproject, lang)
    translation.commit_pending(request)
    autoform = AutoForm(translation, request.POST)
    change = None
    if not translation.subproject.locked and autoform.is_valid():
        if autoform.cleaned_data['inconsistent']:
            units = translation.unit_set.filter_type(
                'inconsistent', translation
            )
        elif autoform.cleaned_data['overwrite']:
            units = translation.unit_set.all()
        else:
            units = translation.unit_set.filter(translated=False)

        sources = Unit.objects.filter(
            translation__language=translation.language,
            translated=True
        )
        if autoform.cleaned_data['subproject'] == '':
            sources = sources.filter(
                translation__subproject__project=translation.subproject.project
            ).exclude(
                translation=translation
            )
        else:
            subprj = SubProject.objects.get(
                project=translation.subproject.project,
                slug=autoform.cleaned_data['subproject']
            )
            sources = sources.filter(translation__subproject=subprj)

        for unit in units.iterator():
            update = sources.filter(checksum=unit.checksum)
            if update.exists():
                # Get first entry
                update = update[0]
                # No save if translation is same
                if unit.fuzzy == update.fuzzy and unit.target == update.target:
                    continue
                # Copy translation
                unit.fuzzy = update.fuzzy
                unit.target = update.target
                # Create signle change object for whole merge
                if change is None:
                    change = Change.objects.create(
                        action=Change.ACTION_AUTO,
                        translation=unit.translation,
                        user=request.user,
                        author=request.user
                    )
                # Save unit to backend
                unit.save_backend(request, False, False)

        messages.info(request, _('Automatic translation completed.'))
    else:
        messages.error(request, _('Failed to process form!'))

    return redirect(translation)
开发者ID:fluentglobe,项目名称:our,代码行数:59,代码来源:edit.py

示例9: lock_translation

def lock_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if not obj.is_user_locked(request):
        obj.create_lock(request.user, True)
        messages.info(request, _('Translation is now locked for you.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:camilonova,项目名称:weblate,代码行数:8,代码来源:lock.py

示例10: unlock_translation

def unlock_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if not obj.is_user_locked(request):
        obj.create_lock(None)
        messages.info(request, _("Translation is now open for translation updates."))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:8,代码来源:lock.py

示例11: unlock_translation

def unlock_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)

    if not obj.is_user_locked(request):
        obj.create_lock(None)
        messages.info(
            request,
            _('Translation is now open for translation updates.')
        )

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:11,代码来源:lock.py

示例12: show_translation

def show_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    last_changes = Change.objects.filter(
        translation=obj
    ).order_by('-timestamp')[:10]

    # Check locks
    obj.is_locked(request)

    # How much is user allowed to configure upload?
    if request.user.has_perm('trans.author_translation'):
        form = ExtraUploadForm()
    elif request.user.has_perm('trans.overwrite_translation'):
        form = UploadForm()
    else:
        form = SimpleUploadForm()

    # Is user allowed to do automatic translation?
    if request.user.has_perm('trans.automatic_translation'):
        autoform = AutoForm(obj)
    else:
        autoform = None

    # Search form for everybody
    search_form = SearchForm()

    # Review form for logged in users
    if request.user.is_anonymous():
        review_form = None
    else:
        review_form = ReviewForm(
            initial={
                'date': datetime.date.today() - datetime.timedelta(days=31)
            }
        )

    return render_to_response('translation.html', RequestContext(request, {
        'object': obj,
        'form': form,
        'autoform': autoform,
        'search_form': search_form,
        'review_form': review_form,
        'last_changes': last_changes,
        'last_changes_rss': reverse(
            'rss-translation',
            kwargs={
                'lang': obj.language.code,
                'subproject': obj.subproject.slug,
                'project': obj.subproject.project.slug
            }
        ),
    }))
开发者ID:msoftware,项目名称:weblate,代码行数:52,代码来源:basic.py

示例13: download_language_pack

def download_language_pack(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    if not obj.supports_language_pack():
        raise Http404('Language pack download not supported')

    filename, mime = obj.store.get_language_pack_meta()

    # Create response
    response = HttpResponse(
        obj.store.get_language_pack(),
        content_type=mime
    )

    # Fill in response headers
    response['Content-Disposition'] = 'attachment; filename=%s' % filename

    return response
开发者ID:spc-12,项目名称:weblate,代码行数:17,代码来源:files.py

示例14: show_translation

def show_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    last_changes = Change.objects.prefetch().filter(translation=obj).order_by("-timestamp")[:10]

    # Check locks
    obj.is_locked(request)

    # How much is user allowed to configure upload?
    if request.user.has_perm("trans.author_translation"):
        form = ExtraUploadForm()
    elif request.user.has_perm("trans.overwrite_translation"):
        form = UploadForm()
    else:
        form = SimpleUploadForm()

    # Is user allowed to do automatic translation?
    if request.user.has_perm("trans.automatic_translation"):
        autoform = AutoForm(obj)
    else:
        autoform = None

    # Search form for everybody
    search_form = SearchForm()

    # Review form for logged in users
    if request.user.is_anonymous():
        review_form = None
    else:
        review_form = ReviewForm(initial={"date": datetime.date.today() - datetime.timedelta(days=31)})

    return render_to_response(
        "translation.html",
        RequestContext(
            request,
            {
                "object": obj,
                "form": form,
                "autoform": autoform,
                "search_form": search_form,
                "review_form": review_form,
                "last_changes": last_changes,
                "last_changes_url": urlencode(obj.get_kwargs()),
                "last_changes_rss": reverse("rss-translation", kwargs=obj.get_kwargs()),
            },
        ),
    )
开发者ID:spc-12,项目名称:weblate,代码行数:46,代码来源:basic.py

示例15: show_translation

def show_translation(request, project, subproject, lang):
    obj = get_translation(request, project, subproject, lang)
    last_changes = Change.objects.prefetch().filter(
        translation=obj
    ).order_by('-timestamp')[:10]

    # Check locks
    obj.is_locked(request)

    # Get form
    form = get_upload_form(request)()

    # Is user allowed to do automatic translation?
    if request.user.has_perm('trans.automatic_translation'):
        autoform = AutoForm(obj)
    else:
        autoform = None

    # Search form for everybody
    search_form = SearchForm()

    # Review form for logged in users
    if request.user.is_anonymous():
        review_form = None
    else:
        review_form = ReviewForm(
            initial={
                'date': datetime.date.today() - datetime.timedelta(days=31)
            }
        )

    return render_to_response('translation.html', RequestContext(request, {
        'object': obj,
        'form': form,
        'autoform': autoform,
        'search_form': search_form,
        'review_form': review_form,
        'last_changes': last_changes,
        'last_changes_url': urlencode(obj.get_kwargs()),
        'last_changes_rss': reverse(
            'rss-translation',
            kwargs=obj.get_kwargs(),
        ),
    }))
开发者ID:fluentglobe,项目名称:our,代码行数:44,代码来源:basic.py


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