Skip to content

Commit 8901c6e

Browse files
committed
📝(docs) Add language configuration documentation
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
1 parent f7d697d commit 8901c6e

File tree

2 files changed

+181
-0
lines changed

2 files changed

+181
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to
1010

1111
- ✨(backend) add documents/all endpoint with descendants #1553
1212
- ✅(export) add PDF regression tests #1762
13+
- 📝(docs) Add language configuration documentation #1757
1314

1415
### Fixed
1516

docs/languages-configuration.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Language Configuration (2025-12)
2+
3+
This document explains how to configure and override the available languages in the Docs application.
4+
5+
## Default Languages
6+
7+
By default, the application supports the following languages (in priority order):
8+
9+
- English (en-us)
10+
- French (fr-fr)
11+
- German (de-de)
12+
- Dutch (nl-nl)
13+
- Spanish (es-es)
14+
15+
The default configuration is defined in `src/backend/impress/settings.py`:
16+
17+
```python
18+
LANGUAGES = values.SingleNestedTupleValue(
19+
(
20+
("en-us", "English"),
21+
("fr-fr", "Français"),
22+
("de-de", "Deutsch"),
23+
("nl-nl", "Nederlands"),
24+
("es-es", "Español"),
25+
)
26+
)
27+
```
28+
29+
## Overriding Languages
30+
31+
### Using Environment Variables
32+
33+
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.
34+
35+
#### Format
36+
37+
The `DJANGO_LANGUAGES` variable expects a semicolon-separated list of language configurations, where each language is defined as `code,Display Name`:
38+
39+
```
40+
DJANGO_LANGUAGES=code1,Name1;code2,Name2;code3,Name3
41+
```
42+
43+
#### Example Configurations
44+
45+
**Example 1: English and French only**
46+
47+
```bash
48+
DJANGO_LANGUAGES=en-us,English;fr-fr,Français
49+
```
50+
51+
**Example 2: Add Italian and Chinese**
52+
53+
```bash
54+
DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch;it-it,Italiano;zh-cn,中文
55+
```
56+
57+
**Example 3: Custom subset of languages**
58+
59+
```bash
60+
DJANGO_LANGUAGES=fr-fr,Français;de-de,Deutsch;es-es,Español
61+
```
62+
63+
### Configuration Files
64+
65+
#### Development Environment
66+
67+
For local development, you can set the `DJANGO_LANGUAGES` variable in your environment configuration file:
68+
69+
**File:** `env.d/development/common.local`
70+
71+
```bash
72+
DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch;it-it,Italiano;zh-cn,中文;
73+
```
74+
75+
#### Production Environment
76+
77+
For production deployments, add the variable to your production environment configuration:
78+
79+
**File:** `env.d/production.dist/common`
80+
81+
```bash
82+
DJANGO_LANGUAGES=en-us,English;fr-fr,Français
83+
```
84+
85+
#### Docker Compose
86+
87+
When using Docker Compose, you can set the environment variable in your `compose.yml` or `compose.override.yml` file:
88+
89+
```yaml
90+
services:
91+
app:
92+
environment:
93+
- DJANGO_LANGUAGES=en-us,English;fr-fr,Français;de-de,Deutsch
94+
```
95+
96+
## Important Considerations
97+
98+
### Language Codes
99+
100+
- Use standard language codes (ISO 639-1 with optional region codes)
101+
- Format: `language-region` (e.g., `en-us`, `fr-fr`, `de-de`)
102+
- Use lowercase for language codes and region identifiers
103+
104+
### Priority Order
105+
106+
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.
107+
108+
### Translation Availability
109+
110+
Before adding a new language, ensure that:
111+
112+
1. Translation files exist for that language in the `src/backend/locale/` directory
113+
2. The frontend application has corresponding translation files
114+
3. All required messages have been translated
115+
116+
#### Available Languages
117+
118+
The following languages have translation files available in `src/backend/locale/`:
119+
120+
- `br_FR` - Breton (France)
121+
- `cn_CN` - Chinese (China) - *Note: Use `zh-cn` in DJANGO_LANGUAGES*
122+
- `de_DE` - German (Germany) - Use `de-de`
123+
- `en_US` - English (United States) - Use `en-us`
124+
- `es_ES` - Spanish (Spain) - Use `es-es`
125+
- `fr_FR` - French (France) - Use `fr-fr`
126+
- `it_IT` - Italian (Italy) - Use `it-it`
127+
- `nl_NL` - Dutch (Netherlands) - Use `nl-nl`
128+
- `pt_PT` - Portuguese (Portugal) - Use `pt-pt`
129+
- `ru_RU` - Russian (Russia) - Use `ru-ru`
130+
- `sl_SI` - Slovenian (Slovenia) - Use `sl-si`
131+
- `sv_SE` - Swedish (Sweden) - Use `sv-se`
132+
- `tr_TR` - Turkish (Turkey) - Use `tr-tr`
133+
- `uk_UA` - Ukrainian (Ukraine) - Use `uk-ua`
134+
- `zh_CN` - Chinese (China) - Use `zh-cn`
135+
136+
**Note:** When configuring `DJANGO_LANGUAGES`, use lowercase with hyphens (e.g., `pt-pt`, `ru-ru`) rather than the directory name format.
137+
138+
### Translation Management
139+
140+
We use [Crowdin](https://crowdin.com/) to manage translations for the Docs application. Crowdin allows our community to contribute translations and helps maintain consistency across all supported languages.
141+
142+
**Want to add a new language or improve existing translations?**
143+
144+
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.
145+
146+
### Cookie and Session
147+
148+
The application stores the user's language preference in a cookie named `docs_language`. The cookie path is set to `/` by default.
149+
150+
## Testing Language Configuration
151+
152+
After changing the language configuration:
153+
154+
1. Restart the application services
155+
2. Verify the language selector displays the correct languages
156+
3. Test switching between different languages
157+
4. Confirm that content is displayed in the selected language
158+
159+
## Troubleshooting
160+
161+
### Languages not appearing
162+
163+
- Verify the environment variable is correctly formatted (semicolon-separated, comma between code and name)
164+
- Check that there are no trailing spaces in language codes or names
165+
- Ensure the application was restarted after changing the configuration
166+
167+
### Missing translations
168+
169+
If you add a new language but see untranslated text:
170+
171+
1. Check if translation files exist in `src/backend/locale/<language_code>/LC_MESSAGES/`
172+
2. Run Django's `makemessages` and `compilemessages` commands to generate/update translations
173+
3. Verify frontend translation files are available
174+
175+
## Related Configuration
176+
177+
- `LANGUAGE_CODE`: Default language code (default: `en-us`)
178+
- `LANGUAGE_COOKIE_NAME`: Cookie name for storing user language preference (default: `docs_language`)
179+
- `LANGUAGE_COOKIE_PATH`: Cookie path (default: `/`)
180+

0 commit comments

Comments
 (0)