I have added new languages to my website and now it is available in English, French and Arabic Everything works fine, I couldn't figure out how to change the default language Currently when the user does not select any language, the site is displayed in English. Some users are complaining that English is not widely used in my country and the site should be in Arabic instead, so I want to do this: if the user does not select any language it will be redirected automatically to arabic.
So when i visit my website like this: http://127.0.0.1:8000/ i will be automatically redirected to: http://127.0.0.1:8000/ar/
Is it possible to do something like this or do I have to change the default code for the whole website.
i have this code in urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('core.urls')),
path('user/',include('users.urls')),
path('dashboard/',include('dashboard.urls')),
path('wallet/',include('wallet.urls')),
path('administration/',include('administration.urls')),
path('chaining/', include('smart_selects.urls')),
path('__debug__/', include(debug_toolbar.urls)),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += i18n_patterns (
path('',include('core.urls')),
path('user/',include('users.urls')),
path('dashboard/',include('dashboard.urls')),
path('wallet/',include('wallet.urls')),
path('administration/',include('administration.urls')),
)
and this is my settings
from django.utils.translation import gettext_lazy as _
LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
LANGUAGE_CODE = 'en'
LANGUAGES =(
('en', ('english')),
('ar', ('Arabic')),
('fr', ('french'))
)