Django application to provide useful utils and reusable parts of code for multi-languages sites.
Project description
django-lang
GitHub
Test
Check Demo Project
- Check the demo repo on GitHub
Requirements
- Python 3.8+ supported.
- Django 3.2+ supported.
Setup
- Install from pip:
pip install django-lang
- Modify
settings.py
by adding the app toINSTALLED_APPS
:INSTALLED_APPS = [ # ... "lang", # ... ]
- Modify
settings.py
by adding the app toINSTALLED_APPS
:TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(PROJECT_DIR, "templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "lang.context_processors.from_settings", ], }, }, ]
- Modify your project's base template
base.html
to include language's switcher styles:<head> ... <link rel="stylesheet" type="text/css" href="{% static 'lang/css/nav-link.css' %}"> ... </head>
- Modify your project's base template
base.html
to include attributes usingtranslate_url
template's tag:<head> ... <meta name="language" content="{{ LANGUAGE_CODE }}" /> {% include "hreflang.html" %} ... </head>
- Modify your project's nav template
nav.html
to include language's switcher:<nav class="navbar"> ... <ul class="nav navbar-nav"> {% include "nav-link.html" %} </ul> ... </nav>
Run Example Project
git clone --depth=50 --branch=django-lang https://github.com/DLRSP/example.git DLRSP/example
cd DLRSP/example
python manage.py runserver
Now browser the app @ http://127.0.0.1:8000
References
- brainstorm.it - Language's switching
- hakibenita.com - Url's translation for "hreflang" html's attributes
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-lang-0.4.2.tar.gz
(15.0 kB
view details)
Built Distribution
File details
Details for the file django-lang-0.4.2.tar.gz
.
File metadata
- Download URL: django-lang-0.4.2.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bde61806b3a4dc88c9691b0937980bfc4aa6a888e8f243ce515adfa2cce87dd |
|
MD5 | 58c6a7975e3bfabe9251383dba0eb90a |
|
BLAKE2b-256 | f072e2d759e460c87c77fa686412da439fe887807e1308dd8a093ee2d0fd8755 |
File details
Details for the file django_lang-0.4.2-py2.py3-none-any.whl
.
File metadata
- Download URL: django_lang-0.4.2-py2.py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11fb3000ea562889b9520ab0afa61349ad57cf5d1c0a162168c6ee348e35cd64 |
|
MD5 | 725f604d6cf2deb9926f045e0d591467 |
|
BLAKE2b-256 | 59f1525fcf13bfca9846bf18d455b32db43e0a7602260664c9dc31f00764e6d0 |