0

I can switch the languages on my website manualy. For example,

If i go to http://127.0.0.1:8000/en/ , my website is in english version.

If i go to http://127.0.0.1:8000/xx/ , my website will switch to the corresponding language.

But i want to write a from so that users can click and then switch the language on my site.

In my template, i wrote something like this:

{% load i18n %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
   <p>Test</p>
{% endfor %}

But the Test did not show up. It seems that the settings.LANGUAGES is not loading properly.

I wrote something like this also not showing up on my site:

{% if LANGUAGES|length > 1 %} 
   <p>Test</p>
{% endif %}

In settings.py:

Added 'django.middleware.locale.LocaleMiddleware' in MIDDLEWARE_CLASSES and LOCALE_PATHS.

I Did not override the LANGUAGES ,just using the LANGUAGES in gobal_settings.py

Any ideas on how to fix this? Thanks.

ctchanac
  • 17
  • 2

1 Answers1

0

I just figrued that i forgot to add

'django.core.context_processors.i18n'

in settings.py Template context_processors

ctchanac
  • 17
  • 2