https://github.com/nidalchateur/multilang_site
blog with django Internationalisation(i18n), chatbot
https://github.com/nidalchateur/multilang_site
bootstrap5 crytography django django-rest-framework dynamic dynamic-search i18n javascript jwt multilanguage
Last synced: 2 months ago
JSON representation
blog with django Internationalisation(i18n), chatbot
- Host: GitHub
- URL: https://github.com/nidalchateur/multilang_site
- Owner: NidalChateur
- License: gpl-3.0
- Created: 2024-06-19T08:14:33.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-07-02T07:00:22.000Z (12 months ago)
- Last Synced: 2024-07-02T23:38:36.980Z (12 months ago)
- Topics: bootstrap5, crytography, django, django-rest-framework, dynamic, dynamic-search, i18n, javascript, jwt, multilanguage
- Language: Python
- Homepage: https://multilang-site-1-joro.onrender.com
- Size: 142 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.python.org/)
[](https://www.djangoproject.com/)
[](https://python-poetry.org/)
[](https://github.com/psf/black)
[](https://github.com/pycqa/flake8)
[](https://hub.docker.com/r/nidalchateur/multilang_site)# Blogs
### Presentation
Blogs is a multilingual deployed application built with :
- Django internationalization (i18n) for language support.
- Django Mail and JWT for password reset functionality.
- Django Admin to manage data.
- OpenAI chatbot for interactive user engagement.
- Cryptography to secure authenticated user data.
- JavaScript and Django REST Framework for dynamic search functionality.
- Pillow to resize and save blog images efficiently.
- Bootstrap for the frontend.### Uses cases
- Logged-in users: You can change the current language (fr-en), create, read, update, and delete (CRUD) posts, and search through them. All of it is possible in the navigation.
- Visitors: You can change the current language (fr-en), read posts and search through the content. All of it is possible in the navigation.
### Run locally the app
0. Set environnement variables1. Install decencies
- `python -m venv env` or `python3 -m venv env`
- `env/scripts/activate` or `source env/bin/activate`
- `pip install -m requirements/dev_freeze.txt`
2. Apply migrations
- `python manage.py migrate`
3. Run
- `python manage.py runserver`
### Translation Steps Documentation (i18n)
0. Configure settings.py, templates and python files
- settings.py :
```
from django.utils.translation import gettext_lazy as _MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",# add this middleware used by i18n
"django.middleware.locale.LocaleMiddleware",
#"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]LOCALE_PATHS = [
BASE_DIR / "locale",
]LANGUAGES = [
("fr", _("French")),
("en", _("English")),
]LANGUAGE_CODE = "en"
TIME_ZONE = "UTC"
USE_I18N = True
USE_TZ = True
USE_L10N = True
```- templates (html files) :
```
{% load i18n %}
{% translate 'No post' %}.
```
- forms.py and models.py :
```
from django.utils.translation import gettext_lazy as _title=_("Title")
```
- views.py :
```
from django.utils.translation import gettext as _title=_("Title")
```
1. Create django.po files for manual translation
`mkdir locale`
`py .\manage.py makemessages -l en --ignore=env/*`
`py .\manage.py makemessages -l fr --ignore=env/*`
2. Update django.po files (if modifications are made)
`py .\manage.py makemessages -a --ignore=env/*`
3. Manually edit the django.po files for translation
Open and edit the generated django.po files in the locale directory. Translate the message strings under each language's respective section (msgid for original text and msgstr for translations).
3. Compile translations
`py .\manage.py compilemessages`