Integrate the UniversalLanguageSelector (ULS) into your Flask application to allow users to easily change their preferred language in which the application is rendered. It is recommended to use this in conjunction with localizing your application.
Usage
In your app.py:
from flask import Flask from flask_uls import ULS app = Flask(__name__) uls = ULS(app)
You can also use the init_app pattern as well.
In your template:
<head>
{% include 'uls/head.html' %}
</head>
<body>
<span class="uls-trigger">Select language</span>
{% include 'uls/footer.html' %}
</body>
This will load the necessary CSS in the header create a button with the text “Select language” to open up the dialog menu and then load the JavaScript to configure and trigger ULS.
To integrate ULS with other localization systems, you can access the uls.language property to get the currently configured language. It will look at the ?uselang query parameter, the language cookie (set by ULS client-side), and the configured default language.
Configuration
ULS_DEFAULT_LANGUAGE (default: 'en'): the language to default to if the user hasn’t selected one.
ULS_ENABLED_LANGUAGES (default: ['en']): languages that ULS should display as options to the user.
Example
See the example application which allows users to change their language between English and German and then outputs the currently chosen language.
License
Flask-ULS is available under the terms of the GPL, version 3 or any later version.
Metadata
Release files for Flask-ULS 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Flask-ULS-0.2.0.tar.gz | 150.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_ULS-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 320.4 kB
Release files / Flask-ULS-0.2.0.tar.gz
| Download URL | Flask-ULS-0.2.0.tar.gz |
|---|---|
| Size | 150.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
758a99921f52a0062f603e07cf4dd8e58915a8859f8f381180946e2feea2a0c7
|
|
BLAKE2b-256 checksum How to use checksums |
f355c22e13130eab313bc972d140640b7b73ad0395775e69929273eeba9b0dc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Release files / Flask_ULS-0.2.0-py3-none-any.whl
| Download URL | Flask_ULS-0.2.0-py3-none-any.whl |
|---|---|
| Size | 169.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
855e8eae6d24cf01ecfedf94ca7486605c8e6a92d2e4973327d3e769beb53f0b
|
|
BLAKE2b-256 checksum How to use checksums |
0fd1ca5c135883abde99750a135a9f399974593ae17e4a2f8f1c003546d8d429
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|