How to use the function in Weblate

To help you get started, we’ve selected a few Weblate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WeblateOrg / weblate / weblate / utils / View on Github external
if isinstance(component, Component):
        kwargs['component_name'] =
        kwargs['component_slug'] = component.slug
        kwargs['component_remote_branch'] = \
        if 'url' not in kwargs:
            kwargs['url'] = get_site_url(component.get_absolute_url())
        project = component.project
        kwargs.pop('component', None)

    if isinstance(project, Project):
        kwargs['project_name'] =
        kwargs['project_slug'] = project.slug
        if 'url' not in kwargs:
            kwargs['url'] = get_site_url(project.get_absolute_url())
        kwargs.pop('project', None)

    with override('en'):
        return Template(
            Context(kwargs, autoescape=False),
github WeblateOrg / weblate / weblate / trans / views / View on Github external
color_list = []
        for color in widget_class.colors:
            kwargs = {
                'project': obj.slug,
                'widget': widget_name,
                'color': color,
                'extension': widget_class.extension,
            if lang is not None:
                kwargs['lang'] = lang
            if component is not None:
                kwargs['component'] = component
            color_url = reverse('widget-image', kwargs=kwargs)
                'name': color,
                'url': get_site_url(color_url),
            'name': widget_name,
            'colors': color_list,
            'verbose': widget_class.verbose,

    return render(
            'engage_url': engage_url,
            'engage_link': engage_link,
            'engage_url_track': engage_url_track,
            'widget_list': widget_list,
            'widget_base_url': widget_base_url,
github WeblateOrg / weblate / weblate / formats / View on Github external
def __init__(self, project=None, language=None, url=None,
                 translation=None, fieldnames=None):
        if translation is not None:
            self.plural = translation.plural
            self.project = translation.component.project
            self.language = translation.language
            self.url = get_site_url(translation.get_absolute_url())
            self.project = project
            self.language = language
            self.plural = language.plural
            self.url = url
        self.fieldnames = fieldnames
github WeblateOrg / weblate / weblate / accounts / View on Github external
def get_context(self, change=None, subscription=None, extracontext=None):
        """Return context for rendering mail"""
        result = {
            'LANGUAGE_CODE': get_language(),
            'LANGUAGE_BIDI': get_language_bidi(),
            'current_site_url': get_site_url(),
            'site_title': settings.SITE_TITLE,
            'notification_name': self.verbose,
        if subscription is not None:
            result['unsubscribe_nonce'] = TimestampSigner().sign(
        if extracontext:
        if change:
            result['change'] = change
            # Extract change attributes
            attribs = (
github WeblateOrg / weblate / weblate / accounts / View on Github external
            for attrib in attribs:
                result[attrib] = getattr(change, attrib)
        if result.get('translation'):
            result['translation_url'] = get_site_url(
        return result
github WeblateOrg / weblate / weblate / trans / models / View on Github external
def get_share_url(self):
        """Return absolute URL usable for sharing."""
        return get_site_url(reverse('engage', kwargs={'project': self.slug}))
github WeblateOrg / weblate / weblate / addons / View on Github external
            target = component
        environment = {
            'WL_VCS': target.vcs,
            'WL_REPO': target.repo,
            'WL_PATH': target.full_path,
            'WL_FILEMASK': component.filemask,
            'WL_TEMPLATE': component.template,
            'WL_NEW_BASE': component.new_base,
            'WL_FILE_FORMAT': component.file_format,
            'WL_BRANCH': component.branch,
            'WL_COMPONENT_SLUG': component.slug,
            'WL_PROJECT_SLUG': component.project.slug,
            'WL_COMPONENT_URL': get_site_url(component.get_absolute_url()),
            'WL_ENGAGE_URL': component.get_share_url(),
        if translation:
            environment['WL_LANGUAGE'] = translation.language_code
        if env is not None:
        self.execute_process(component, command, environment)