Skip to main content

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 .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.0.tar.gz (3.1 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.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

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

Hashes for fluent_manager-1.0.0.tar.gz
Algorithm Hash digest
SHA256 818a003fdf7f38a101681cbda3c7e32ee81e2be993e55342cfc2fc41bd48142f
MD5 0b34a2754bf8f01daaa0d2cd7eb7d0c2
BLAKE2b-256 80950f3699df16f8075068842a722a4b4b362cf34a9b7c3cb57640f1228d6597

See more details on using hashes here.

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

Hashes for fluent_manager-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 647fffd733b91eaed6da9f98b70dd19dd93f8519f0b86825c7719db7a5ca2ed5
MD5 602348499a1bf5b0d56c2eddfc76f440
BLAKE2b-256 aba858e4bbf8333bd918c5ad18fc7a13a4e10aa2ffb27bc7d5a804ac06e869f2

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