Skip to content

Commit 34bd087

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 a920daf commit 34bd087

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed

docs/languages-configuration.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
139+
140+
### Cookie and Session
141+
142+
The application stores the user's language preference in a cookie named `docs_language`. The cookie path is set to `/` by default.
143+
144+
## Testing Language Configuration
145+
146+
After changing the language configuration:
147+
148+
1. Restart the application services
149+
2. Verify the language selector displays the correct languages
150+
3. Test switching between different languages
151+
4. Confirm that content is displayed in the selected language
152+
153+
## Troubleshooting
154+
155+
### Languages not appearing
156+
157+
- Verify the environment variable is correctly formatted (semicolon-separated, comma between code and name)
158+
- Check that there are no trailing spaces in language codes or names
159+
- Ensure the application was restarted after changing the configuration
160+
161+
### Missing translations
162+
163+
If you add a new language but see untranslated text:
164+
165+
1. Check if translation files exist in `src/backend/locale/<language_code>/LC_MESSAGES/`
166+
2. Run Django's `makemessages` and `compilemessages` commands to generate/update translations
167+
3. Verify frontend translation files are available
168+
169+
## Related Configuration
170+
171+
- `LANGUAGE_CODE`: Default language code (default: `en-us`)
172+
- `LANGUAGE_COOKIE_NAME`: Cookie name for storing user language preference (default: `docs_language`)
173+
- `LANGUAGE_COOKIE_PATH`: Cookie path (default: `/`)
174+

0 commit comments

Comments
 (0)