Skip to main content

Lightweight Fluent localisation manager with automatic locale fallback

Project description

fluent-manager

DOI PyPI Downloads PyPI - License PyPI - Version

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.

AI Agent Skill

This repository contains a specialised skill for AI agents (such as Gemini CLI). It helps the agent provide expert assistance in writing Python code and integrating this library into your projects.

To install the skill, run:

npx skills add BogdanovychA/fluent-manager --skill fluent-manager

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.2.tar.gz (4.5 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.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fluent_manager-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 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.2.tar.gz
Algorithm Hash digest
SHA256 4269804e8321b916510c1b0eaca3433dabaca92ad6f5b4725a933b24019b5607
MD5 acc270b82fc0ceb303fa305b3a338856
BLAKE2b-256 c6d7e5e3c3a714bfb625945e9cc3f82512d45ece439d19da5a00d6d0ef9ddf77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fluent_manager-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24781ef9c41ce4da917fb4eeb1e1b173b7869bf7bda09d5370cb413a1a462400
MD5 ccef37c9febbaf639453a8ee54b6228a
BLAKE2b-256 fdedf2e24db2c28fbcd358505e8ce7d1e267bde947eb986167c33e59551aeebc

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