Add comprehensive guide explaining how to override LANGUAGES settings using the DJANGO_LANGUAGES environment variable. Documentation includes: - Default language configuration - Environment variable format and examples - Configuration for development, production, and Docker Compose - Complete list of 15 available languages with translation files - Language code formatting guidelines - Testing and troubleshooting sections
5.6 KiB
Language Configuration (2025-12)
This document explains how to configure and override the available languages in the Docs application.
Default Languages
By default, the application supports the following languages (in priority order):
- English (en-us)
- French (fr-fr)
- German (de-de)
- Dutch (nl-nl)
- Spanish (es-es)
The default configuration is defined in src/backend/impress/settings.py:
LANGUAGES = values.SingleNestedTupleValue(
(
("en-us", "English"),
("fr-fr", "Français"),
("de-de", "Deutsch"),
("nl-nl", "Nederlands"),
("es-es", "Español"),
)
)
Overriding Languages
Using Environment Variables
You can override the available languages by setting the DJANGO_LANGUAGES environment variable. This is the recommended approach for customizing language support without modifying the source code.
Format
The DJANGO_LANGUAGES variable expects a semicolon-separated list of language configurations, where each language is defined as code,Display Name:
DJANGO_LANGUAGES=code1,Name1;code2,Name2;code3,Name3
Example Configurations
Example 1: English and French only
DJANGO_LANGUAGES=en-us,English;fr-fr,Français
Example 2: Add Italian and Chinese
DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch;it-it,Italiano;zh-cn,中文
Example 3: Custom subset of languages
DJANGO_LANGUAGES=fr-fr,Français;de-de,Deutsch;es-es,Español
Configuration Files
Development Environment
For local development, you can set the DJANGO_LANGUAGES variable in your environment configuration file:
File: env.d/development/common.local
DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch;it-it,Italiano;zh-cn,中文;
Production Environment
For production deployments, add the variable to your production environment configuration:
File: env.d/production.dist/common
DJANGO_LANGUAGES=en-us,English;fr-fr,Français
Docker Compose
When using Docker Compose, you can set the environment variable in your compose.yml or compose.override.yml file:
services:
app:
environment:
- DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch
Important Considerations
Language Codes
- Use standard language codes (ISO 639-1 with optional region codes)
- Format:
language-region(e.g.,en-us,fr-fr,de-de) - Use lowercase for language codes and region identifiers
Priority Order
Languages are listed in priority order. The first language in the list is used as the fallback language throughout the application when a specific translation is not available.
Translation Availability
Before adding a new language, ensure that:
- Translation files exist for that language in the
src/backend/locale/directory - The frontend application has corresponding translation files
- All required messages have been translated
Available Languages
The following languages have translation files available in src/backend/locale/:
br_FR- Breton (France)cn_CN- Chinese (China) - Note: Usezh-cnin DJANGO_LANGUAGESde_DE- German (Germany) - Usede-deen_US- English (United States) - Useen-uses_ES- Spanish (Spain) - Usees-esfr_FR- French (France) - Usefr-frit_IT- Italian (Italy) - Useit-itnl_NL- Dutch (Netherlands) - Usenl-nlpt_PT- Portuguese (Portugal) - Usept-ptru_RU- Russian (Russia) - Useru-rusl_SI- Slovenian (Slovenia) - Usesl-sisv_SE- Swedish (Sweden) - Usesv-setr_TR- Turkish (Turkey) - Usetr-truk_UA- Ukrainian (Ukraine) - Useuk-uazh_CN- Chinese (China) - Usezh-cn
Note: When configuring DJANGO_LANGUAGES, use lowercase with hyphens (e.g., pt-pt, ru-ru) rather than the directory name format.
Translation Management
We use Crowdin to manage translations for the Docs application. Crowdin allows our community to contribute translations and helps maintain consistency across all supported languages.
Want to add a new language or improve existing translations?
If you would like us to support a new language or want to contribute to translations, please get in touch with the project maintainers. We can add new languages to our Crowdin project and coordinate translation efforts with the community.
Cookie and Session
The application stores the user's language preference in a cookie named docs_language. The cookie path is set to / by default.
Testing Language Configuration
After changing the language configuration:
- Restart the application services
- Verify the language selector displays the correct languages
- Test switching between different languages
- Confirm that content is displayed in the selected language
Troubleshooting
Languages not appearing
- Verify the environment variable is correctly formatted (semicolon-separated, comma between code and name)
- Check that there are no trailing spaces in language codes or names
- Ensure the application was restarted after changing the configuration
Missing translations
If you add a new language but see untranslated text:
- Check if translation files exist in
src/backend/locale/<language_code>/LC_MESSAGES/ - Run Django's
makemessagesandcompilemessagescommands to generate/update translations - Verify frontend translation files are available
Related Configuration
LANGUAGE_CODE: Default language code (default:en-us)LANGUAGE_COOKIE_NAME: Cookie name for storing user language preference (default:docs_language)LANGUAGE_COOKIE_PATH: Cookie path (default:/)