Ejemplo n.º 1
0
 def process_request(self, request):
     domain = get_domain()
     host = request.get_host()
     user = request.user
     lang = get_language_key(host, domain, user)
     translation.activate(lang)
     request.LANGUAGE_CODE = translation.get_language()
Ejemplo n.º 2
0
 def process_request(self, request):
     domain = get_domain()
     host = request.get_host()
     user = request.user
     lang = get_language_key(host, domain, user)
     translation.activate(lang)
     request.LANGUAGE_CODE = translation.get_language()
Ejemplo n.º 3
0
    def get_domain_for_request(self, request):
        """
        Returns the domain that will be used to identify the subdomain part
        for this request.
        """

        return get_domain()
Ejemplo n.º 4
0
def multilingual_meta(full_path):
    """Returns a list of multilingual metatags according to Google Webmaster guidelines"""
    domain = get_domain()

    data = []
    for l in settings.LANGUAGES:
        tmp = {}
        tmp["key"] = l[0]
        tmp["url"] = "http://" + l[0] + "." + domain + full_path
        data.append(tmp)

    value = {"languages": data}

    return value
Ejemplo n.º 5
0
def language_switch(full_path):
    """returns a language switching widget"""
    domain = get_domain()

    data = []
    for l in settings.LANGUAGES:
        tmp = {}
        tmp["key"] = l[0]
        tmp["url"] = "http://" + l[0] + "." + domain + full_path
        data.append(tmp)

    value = {"languages": data}

    return value
Ejemplo n.º 6
0
def multilingual_meta(full_path):
    """Returns a list of multilingual metatags according to Google Webmaster guidelines"""
    domain = get_domain()

    data = []
    for l in settings.LANGUAGES:
        tmp = {}
        tmp['key'] = l[0]
        tmp['url'] = 'http://' + l[0] + '.' + domain + full_path
        data.append(tmp)

    value = {
        'languages': data
    }

    return value
Ejemplo n.º 7
0
def language_switch(full_path):
    """returns a language switching widget"""
    domain = get_domain()

    data = []
    for l in settings.LANGUAGES:
        tmp = {}
        tmp['key'] = l[0]
        tmp['url'] = 'http://' + l[0] + '.' + domain + full_path
        data.append(tmp)

    value = {
        'languages': data
    }

    return value
Ejemplo n.º 8
0
    def process_request(self, request):
        """
        Adds a ``subdomain`` attribute to the ``request`` parameter.
        """
        domain, host = map(lower, (get_domain(), request.get_host()))

        pattern = r'^(?:(?P<subdomain>.*?)\.)?%s(?::.*)?$' % re.escape(domain)
        matches = re.match(pattern, host)

        if matches:
            request.subdomain = matches.group('subdomain')
        else:
            request.subdomain = None
            logger.warning(
                'The host %s does not belong to the domain %s, '
                'unable to identify the subdomain for this request',
                request.get_host(), domain)
Ejemplo n.º 9
0
def reverse(viewname, subdomain=None, scheme=None, args=None, kwargs=None,
        current_app=None):
    """
    Reverses a URL from the given parameters, in a similar fashion to
    :meth:`django.core.urlresolvers.reverse`.

    :param viewname: the name of URL
    :param subdomain: the subdomain to use for URL reversing
    :param scheme: the scheme to use when generating the full URL
    :param args: positional arguments used for URL reversing
    :param kwargs: named arguments used for URL reversing
    :param current_app: hint for the currently executing application
    """
    urlconf = settings.SUBDOMAIN_URLCONFS.get(subdomain, settings.ROOT_URLCONF)

    domain = get_domain()
    if subdomain is not None:
        domain = '%s.%s' % (subdomain, domain)

    path = simple_reverse(viewname, urlconf=urlconf, args=args, kwargs=kwargs,
        current_app=current_app)
    return urljoin(domain, path, scheme=scheme)
Ejemplo n.º 10
0
 def get_domain_for_request(self, request):
     """
     Returns the domain that will be used to identify the subdomain part
     for this request.
     """
     return get_domain()