laura-barluzzi / django-user-language-middleware

Django middleware to translate with language in user model
Apache License 2.0
12 stars 2 forks source link

Django Cookie based language #5

Open infosrabah opened 4 years ago

infosrabah commented 4 years ago

Hi Laura,

Is there a way to have a 'django-user-language-middleware' working as a "cookie" language switcher rather than "session" based one ? Since this is deprecated in Django 3.0:

Deprecated since version 3.0: The language won’t be stored in the session in Django 4.0. Use the LANGUAGE_COOKIE_NAME cookie instead.

Source : Use the LANGUAGE_COOKIE_NAME cookie instead

Source 2 : [Because accessing the language in the session rather than in the cookie is deprecated, LocaleMiddleware no longer looks for the user’s language in the session and django.contrib.auth.logout() no longer preserves the session’s language after logout. thank you].(https://docs.djangoproject.com/en/dev/releases/3.0/#miscellaneous)

thank you.

laura-barluzzi commented 4 years ago

@infosrabah sorry for the late reply. It was a busy period in my life. Thank you for flagging this recent Django update. I will surely have a look into it and hopefully get a fix out soon!

infosrabah commented 4 years ago

It's ok,

Hope everything is ok for you now ;)

But since I haven't heard from you, I did some hack to make it work. ans stopped to work with the middleware.

hope to see a fix soon.

Skrattoune commented 2 years ago

any news on this ? Would be great to have a fix ... or we would need to move to another middleware Any suggestion ?

Skrattoune commented 1 year ago

OK, after a few hours research for a replacement, I figured out only a minor tweak is needed, as already performed by Tatu Wikman @tswfi: https://github.com/tswfi/django-user-language-middleware/tree/tswfi-patch-1

It would be great to have this available directly through pip

If you are too constrained by time, maybe you could hand over the lead on this package to someone more active on Github. Bcause I find it extremely useful and easy for someone like me who is not an everyday coder.

tswfi commented 1 year ago

Already forgot that fork :D

I actually just implemented the functionality into my project directly. One less requirement to keep up with :)