Update 'Internationalization'

Danhia 2022-02-16 12:45:55 +01:00
parent f7b3fc38ca
commit 6830b03fb2
1 changed files with 66 additions and 66 deletions

@ -1,66 +1,66 @@
# Internationalization # Internationalization
Internationalization configuration in `settings.py` : Internationalization configuration in `settings.py` :
```python ```python
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/ # https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_NAME = 'django_language' LANGUAGE_COOKIE_NAME = 'django_language'
USE_I18N = True USE_I18N = True
LANGUAGES = ( LANGUAGES = (
('en', _("English")), ('en', _("English")),
('de', _('German')), ('de', _('German')),
('fr', _('French')), ('fr', _('French')),
('ru', _('Russian')), ('ru', _('Russian')),
) )
``` ```
`LANGUAGES` list of languages supported. `LANGUAGES` list of languages supported.
## Locale directory ## Locale directory
All lang files where traductions is stored are located into `locale/`. All lang files where traductions are stored are located into `locale/` and `ressources/locale`.
For translations, edit file `locale/[lang]/django.po` : For translations, edit file `locale/[lang]/django.po` :
```python ```python
#: accounts/templates/accounts/edit.html:44 #: accounts/templates/accounts/edit.html:44
msgid "Connected accounts" msgid "Connected accounts"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:51 #: accounts/templates/accounts/edit.html:51
msgid "Disconnect Discord" msgid "Disconnect Discord"
msgstr "" msgstr ""
``` ```
For all `messages`, we have a list of `path to files` containing this `message` and line number. For all `messages`, we have a list of `path to files` containing this `message` and line number.
Edit `msgstr` with the translated string. Edit `msgstr` with the translated string.
## Make messages ## Make messages
To create all .po files, run this command : To create all .po files, run this command :
```bash ```bash
django-admin makemessages -l [LANG_CODE] django-admin makemessages -l [LANG_CODE]
``` ```
`LANG_CODE` for exemple can be set to 'ru', 'fr', 'en'... `LANG_CODE` for exemple can be set to 'ru', 'fr', 'en'...
## Compile `messages` ## Compile `messages`
To compile messages run this command : To compile messages run this command :
```bash ```bash
manage.py compilemessages manage.py compilemessages
``` ```
## Contributing ## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.