Commit 2e3c0e5da88cf0d9bb9f7748f2dcc6029cc6b29f
1 parent
d3f8848e
Exists in
master
and in
34 other branches
Created a middleware to force default translation
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Matheus Fernandes <matheus.souza.fernandes@gmail.com>
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,9 @@ |
1 | +from django.conf import settings | |
2 | +from django.utils import translation | |
3 | + | |
4 | +class ForceLangMiddleware: | |
5 | + | |
6 | + def process_request(self,request): | |
7 | + request.LANG = getattr(settings,'LANGUAGE_CODE',settings.LANGUAGE_CODE) | |
8 | + translation.activate(request.LANG) | |
9 | + request.LANGUAGE_CODE = request.LANG | ... | ... |