Django authentication and social-sign on with django-allauth

How do translations and localization work in Django?

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

Modified files

Dockerfile
--- 
+++ 
@@ -1,5 +1,8 @@
 FROM python:3.12-bullseye
 ENV PYTHONUNBUFFERED=1
+
+RUN apt update
+RUN apt install gettext -y

 RUN mkdir /code
djangocourse/settings.py
--- 
+++ 
@@ -149,13 +149,17 @@
 # Internationalization
 # https://docs.djangoproject.com/en/5.1/topics/i18n/

-LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'es'  # remember to change this back to en-us!

 TIME_ZONE = 'UTC'

 USE_I18N = True

 USE_TZ = True
+
+LOCALE_PATHS = [
+    BASE_DIR / "locale"
+]


 # Static files (CSS, JavaScript, Images)