26👍
Default language strings are not stored in po/mo files, they go directly in code and templates – seems that you have this right.
You can switch back to it, by setting the session variable django_language
back to dutch.
Ensure, that you have your settings set the right way:
LANGUAGE_CODE = 'nl' #default language
LANGUAGES = (
('nl', _('Dutch')),
('fr', _('French')),
)
Don’t forget, that you don’t have to write code to switch between languages by your self. Better to use special django view (quote from django book):
As a convenience, Django comes with a view, django.views.i18n.set_language, that sets a user’s language preference and redirects back to the previous page.
Activate this view by adding the following line to your URLconf:
(r'^i18n/', include('django.conf.urls.i18n')),
3👍
this question and answers could be helpful – set language within a django view
Don’t forget to use translation.activate(lang_code)
, this is really important.
You can use standard way to change languages with the post method or write your own middleware and change it for example in the url then.
Cheers,
Ignas
- How to disable HTML encoding when using Context in django
- Have a url that accepts all characters
- Sometimes request.session.session_key is None
- Convert Python None to JavaScript null
1👍
If you use {% url web-language 'nl-nl' %}
like this 'nl-nl'
is in your args
(args[0]
), not in your kwargs
. For kwargs
you should use syntax like {% url web-language language='nl-nl' %}
. Then your view should work. Hopefully your urlconf matches the way the view is dealing with it.
- Django order_by a property
- You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
- Django ForeignKey limit_choices_to a different ForeignKey id
- Creating UTF-8 JsonResponse in Django
- Django makemigrations not detecting project/apps/myapp