internationalization - django - understanding LocaleMiddleWare (translation.deactivate) -
i use django.middleware.locale.localemiddleware website i18n'ed , make language 'switcher' via set_language redirect.
and can not understand couple of things:
why call
translation.deactivate
(source on github) during process_responce?does mean can not using middleware? (it shows page in different language once, , switches back.)
translation.deactivate
called because current language stored in global (thread local) variable. set when request comes in, , must un-set when request finished prevent "leaking" next request (ex, imagine thread handles request must localized portuguese, request no localization set. if portuguese localization wasn't deactivated, next request localized portuguese).
Comments
Post a Comment