0

I am changing the language runtime and updating it in the session variable.

I needed to call a function which will run before each method call as the language must be activated for each request. For this, I've written a middleware where in the "process_request" and the "process_response" functions, I am reading the language from session and activating it.

It is working properly in the html files (i.e. inside templates) but the text coming from the *.py files are not getting updated immediately. Not even after restarting the server or even after deleting the *.pyc files.

If I don't perform any activity in the site for 20-30 seconds then after reloading the language got updated for *.py file's text also.

halfer
  • 19,824
  • 17
  • 99
  • 186
Richa
  • 155
  • 1
  • 7

1 Answers1

0

For the translation, I was using ugettext() of django.utils.translation.

By changing it from ugettext() to ugettext_lazy() worked for me.

For more information about ugettext_lazy, refer When should I use ugettext_lazy?

Community
  • 1
  • 1
Richa
  • 155
  • 1
  • 7