Lightweight Fluent localisation manager with automatic locale fallback
Project description
fluent-manager
Translations: 🇺🇦 Українська · 🇵🇱 Polski
Lightweight Project Fluent localisation manager with automatic locale fallback.
Installation
pip install fluent-manager
Features
- Simple API for retrieving localised strings
- Automatic fallback chain: preferred locales → default locale → key itself
- Auto-discovery of available locales and
.ftlresource files from the filesystem - Supports multiple preferred locales in priority order
Directory structure
locales/
├── en/
│ └── messages.ftl
├── uk/
│ └── messages.ftl
└── pl/
└── messages.ftl
Usage
from fluent_manager import FluentManager
lang_manager = FluentManager(
locales=["uk", "pl"],
locales_path="/path/to/locales",
default_locale="en",
)
# Returns localised string in the first matching locale
message = lang_manager.get("welcome-message", user_name="Andrii")
Fallback behaviour
| Situation | Result |
|---|---|
| Key exists in first preferred locale | Renders in first preferred locale |
| Key missing in first locale, exists in next | Renders in next preferred locale |
| Key exists only in default locale | Renders in default locale |
| Key missing in all locales | Returns the key itself |
API
FluentManager(locales, locales_path, default_locale=None)
| Parameter | Type | Description |
|---|---|---|
locales |
list |
Preferred locales in priority order, e.g. ["uk", "pl"] |
locales_path |
str |
Path to the directory containing locale subdirectories |
default_locale |
str | None |
Fallback locale. Defaults to "en" |
FluentManager.get(key, **kwargs) -> str
Retrieves a localised string by key with optional variables.
FluentManager.languages -> list
List of all available locales detected from the filesystem.
Links
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fluent_manager-1.0.0.tar.gz.
File metadata
- Download URL: fluent_manager-1.0.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818a003fdf7f38a101681cbda3c7e32ee81e2be993e55342cfc2fc41bd48142f
|
|
| MD5 |
0b34a2754bf8f01daaa0d2cd7eb7d0c2
|
|
| BLAKE2b-256 |
80950f3699df16f8075068842a722a4b4b362cf34a9b7c3cb57640f1228d6597
|
File details
Details for the file fluent_manager-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fluent_manager-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
647fffd733b91eaed6da9f98b70dd19dd93f8519f0b86825c7719db7a5ca2ed5
|
|
| MD5 |
602348499a1bf5b0d56c2eddfc76f440
|
|
| BLAKE2b-256 |
aba858e4bbf8333bd918c5ad18fc7a13a4e10aa2ffb27bc7d5a804ac06e869f2
|