[Answered ]-Django – understanding LocaleMiddleWare (translation.deactivate)

2👍

translation.deactivate is called because the current language is stored in a global (thread local) variable. It is set when a request comes in, and must be un-set when that request is finished to prevent it “leaking” into the next request (ex, imagine a thread handles a request which must be localized to Portuguese, then another request where no localization is set. If Portuguese localization wasn’t deactivated, the next request would also be localized to Portuguese).

Leave a comment