Only by invoking multilingual.languages.set_default_language() or
there is ability to make it automaticly by default django's
"request.LANGUAGE_CODE".
I'm trying to grow friendship between multilingual and localeurl.
Localeurl changing LANGUAGE_CODE and I want it to cause multilingual
language switching too.
Two hours of multilingual code inspecting brings zero results. :)
Thanks.
class LocaleURLMiddleware(object):
def __init__(self):
# ========<some code missed here>============
if "multilingual" in settings.INSTALLED_APPS:
try:
self.switch_ml = settings.ALLOW_LOCALEURL #settings
variable to turn on/off feature
except:
self.switch_ml = False #False by deafault
if self.switch_ml:
from multilingual.languages import set_default_language
self.ml_switch_lang=set_default_language
def process_request(self, request):
# ==========<some code missed here>============
if self.switch_ml:
self.ml_switch_lang(request.LANGUAGE_CODE)
It's working now, bu it's a "dirty hack".
Still looking for "nice and simple" solution... :-)
Kind regards,
Kirill Zaborsky
On Feb 17, 2:39 pm, "Dmitry A. Erokhin" <dmitry.erok...@gmail.com>
wrote:
On 23 фев, 16:27, qrilka <qri...@gmail.com> wrote:
> I think multilingual.middleware.DefaultLanguageMiddleware is supposed
> to do the switching but I could not get it working :(
>
> Kind regards,
> Kirill Zaborsky
Thanks a lot, Kirill!
It works fine now without any hacks. :)
I haven't read about middleware in docs – stupid mistake, I know...