Some language tools for Django.
Project description
Some language tools for Django.
Installation
Install with pip:
$ pip install django-ok-language-tools
Update INSTALLED_APPS:
INSTALLED_APPS = [
...
'ok_language_tools',
...
]
Available settings
LANGUAGE_TOOLS_REDIRECT_TO_QUERY_PARAMETER - Query parameter to get next url for ‘set_language’ view.
LANGUAGE_TOOLS_LANGUAGE_QUERY_PARAMETER - Query parameter to get languge to translate next url for ‘set_language’ view.
LANGUAGE_TOOLS_REDIRECT_EXCLUDE_PREFIXES - Tuple of prefixes to skip redirect for ‘language_redirect_middleware’.
For example:
LANGUAGE_TOOLS_REDIRECT_EXCLUDE_PREFIXES = (
'/api/v1/',
'/uploads/',
'/static/',
)
LANGUAGE_TOOLS_DEFAULT_REDIRECT_LANGUAGE - Language code to redirect for a first user visit.
LANGUAGE_TOOLS_VISITED_SESSION_KEY - Key to store visited state in session.
Quickstart
Add ‘language_redirect_middleware’ to the MIDDLEWARE configuration to redirect users to default language during a first visit:
MIDDLEWARE = [
...
'ok_language_tools.middleware.language_redirect_middleware'
]
To enable ‘set_language’ view, add next URL patterns:
urlpatterns = [
...
path('', include('ok_language_tools.urls')),
]
language_url = reverse('ok-language-tools:set-language')
catalog_url = '/catalog/'
language = 'uk'
set_language_url = f'{language_url}?redirect_to={catalog_url}&language={language}'
# or using HTTP_REFERER
set_language_url = f'{language_url}?language={language}'
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
Built Distribution
File details
Details for the file django-ok-language-tools-0.0.4.tar.gz
.
File metadata
- Download URL: django-ok-language-tools-0.0.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce01b6d389a83586d54645b86275edfb77e2f818a44c86fbc04b6b2261ae19e6 |
|
MD5 | d339721be360f32f966a23df9026ed92 |
|
BLAKE2b-256 | b58139fb008d09134aa670d9238cf8584fa23ba31cf69b8bd332e4d272e70b4e |
File details
Details for the file django_ok_language_tools-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: django_ok_language_tools-0.0.4-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5753976b5c449bd5265fb3ded7785bb995c5d46b4a841325cf256ffa734cb696 |
|
MD5 | 3d5a0aad6b43d5fab08eb7f6e86a24d6 |
|
BLAKE2b-256 | 80a36c17ed49c18eb6c656ef22fccf62f15ad212320593efbbc0cbcca2bf3313 |