Skip to main content

Lightweight Fluent localisation manager with automatic locale fallback

Project description

fluent-manager

DOI PyPI Downloads

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 .ftl resource 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluent_manager-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluent_manager-1.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file fluent_manager-1.0.1.tar.gz.

File metadata

  • Download URL: fluent_manager-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for fluent_manager-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8dfbacc1f78167e0184175f4caa9387d8a98dc97d1565745de4f9d3e6097d770
MD5 af01b1b0767e4dd379104df79a8ac4d4
BLAKE2b-256 55c8bc2fa75f3c54ea9817e022d4243817596c76e92d7a55df65c5ff3ac46bf5

See more details on using hashes here.

File details

Details for the file fluent_manager-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fluent_manager-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for fluent_manager-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72aaca8d3371546f439da53a16829d3771821ef5687ab5efe90a850668800e72
MD5 51b9f3d77123460861617baf1bf91b50
BLAKE2b-256 4e8303abd71aa67ad0f7858e8c9889ab1e9a877143d5a5efe46ef43af8971b4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page