infamily / infinity1.0

Infty 1.0 Ɣ
https://infty.xyz
1 stars 0 forks source link

Language selection and different domains #307

Open aliev opened 8 years ago

aliev commented 8 years ago

Language switching does not work in a domain that has already been assigned to the language. The middleware class: https://github.com/WeFindX/infinity/blob/master/src/apps/core/middleware/language.py

It is necessary to apply the decorator for the function and change the logic of its work. The view of language switcher: https://github.com/django/django/blob/master/django/views/i18n.py#L28

Usage example (with new decorator)

from core.utils import custom_set_language
url(r'^set-language/$', custom_set_language(set_language), name="custom_set_language"),

Decorator description

def custom_set_language(func):
    def wrapper(request):
        return func(request)
    return wrapper