May 2018
Beginner to intermediate
526 pages
11h 57m
English
Since we are serving content that is available in multiple languages, we should let our users switch the site's language. We are going to add a language selector to our site. The language selector will consist of a list of available languages, which are displayed using links.
Edit the shop/base.html template of the shop application and find the following lines:
<div id="header"> <a href="/" class="logo">{% trans "My shop" %}</a></div>
Replace them with the following code:
<div id="header"> <a href="/" class="logo">{% trans "My shop" %}</a> {% get_current_language as LANGUAGE_CODE %} {% get_available_languages as LANGUAGES %} {% get_language_info_list for LANGUAGES as languages %} <div class="languages">Read now
Unlock full access