I have developed a web application in 2 languages, where users can change in-between them using the UI, and it all works fine, the language is changing. What I cant setup is the default language that is working when the application is opened for the first time. This is my settings.py
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
LANGUAGE_CODE = 'az'
USE_I18N = True
LOCALE_PATHS = [
os.path.join(BASE_DIR, 'locale'),
]
LANGUAGES = [
('az', 'Azerbaijani'),
('en', 'English'),
]
urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('i18n/', include('django.conf.urls.i18n')),
]
urlpatterns += i18n_patterns(
path('', include('main.urls')), # Include your app's URLs
)
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)