Skip to main content

Python runtime for the Fluent (FTL) specification: bidirectional parsing, CLDR-backed locale-aware formatting, and fail-fast boot validation with structured audit evidence.

Project description

FTLLexEngine — Fluent runtime for real-world localization

FTLLexEngine is a Python runtime and parsing toolkit for Fluent .ftl resources, built for teams that need locale-aware text, money, dates, and user-input parsing without rebuilding the same rules in application code.

If you are still stitching this together with string interpolation, one-off parsers, and per-locale edge-case fixes, the same bug tends to get fixed in three places.

PyPI Python Versions License: MIT

  • Keep plural rules and locale formatting in .ftl, close to the messages themselves.
  • Parse localized numbers, dates, and currency back into exact Python types.
  • Fail startup early when resources or message schemas drift.
  • Share internally synchronized bundles safely across concurrent requests.

The nearby alternative is a mix of hand-kept formatting rules, ad-hoc parsing helpers, and translation checks that only happen after a request is already live. FTLLexEngine turns that into one repeatable runtime.

Try a working snippet · Take the deeper workflow tour · Get the package on PyPI

One Small Workflow

For a coffee exporter, one invoice line and one buyer reply are enough to create drift: display logic in one place, parsing logic in another, validation nowhere. FTLLexEngine keeps that move in one stack.

from decimal import Decimal
from ftllexengine import FluentBundle
from ftllexengine.parsing import parse_currency

bundle = FluentBundle("de_DE", use_isolating=False)
bundle.add_resource('quote = Angebot: { CURRENCY($amount, currency: "EUR") }')

text, errors = bundle.format_pattern("quote", {"amount": Decimal("12450.00")})
assert errors == ()
assert text == "Angebot: 12.450,00\u00a0€"

parsed, errors = parse_currency("12.450,00 EUR", "de_DE", default_currency="EUR")
assert errors == ()
assert parsed == (Decimal("12450.00"), "EUR")

The same locale-aware runtime formats the outgoing quote and parses the buyer’s reply back into an exact Decimal.

Where It Fits

Use FTLLexEngine when the same message has to survive more than one locale, more than one direction, or more than one layer of your system.

  • Good fit: Fluent-based apps, invoice and checkout flows, localized forms, startup validation for translation packs, and systems that care about exact decimals instead of float luck.
  • Good fit: Teams that want message grammar, money formatting, and localized input parsing to stay consistent instead of drifting between templates, helpers, and validation code.
  • Keep it simple: single-locale apps, plain string formatting, or projects that do not need Fluent at all.

Start In Two Paths

Use the full runtime when you need formatting, localization orchestration, and localized parsing:

uv add ftllexengine[babel]

Use the parser-only install when you only need syntax parsing, AST work, validation, and zero-dependency helper surfaces:

uv add ftllexengine

Start from the path that matches your job:

Why It Feels Safe To Try

  • Published on PyPI for Python 3.13+.
  • Built around the Fluent specification and CLDR-backed locale data via Babel.
  • Fully typed, MIT-licensed, and shipped with runnable examples plus repository checks for docs, examples, and version sync.
  • Supports parser-only installs for syntax and validation work when you do not need the Babel-backed runtime surface.
  • Release and publishing steps live in docs/RELEASE_PROTOCOL.md.

Legal

FTLLexEngine is MIT-licensed. The optional babel extra adds Babel under BSD-3-Clause terms. FTLLexEngine is an independent implementation of the Fluent syntax specification and is not affiliated with or endorsed by Mozilla.

LICENSE · NOTICE · PATENTS.md

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

ftllexengine-0.165.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

ftllexengine-0.165.0-py3-none-any.whl (276.1 kB view details)

Uploaded Python 3

File details

Details for the file ftllexengine-0.165.0.tar.gz.

File metadata

  • Download URL: ftllexengine-0.165.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ftllexengine-0.165.0.tar.gz
Algorithm Hash digest
SHA256 822b9ec1c212e112c19d85c462be4664d5bbfa74cad077205bb8ba028ab2d1a7
MD5 cb8f64489c7d34db299e0cd4be2b0e41
BLAKE2b-256 dd7099e576b85b5a24c666853dcdde88f44a5211d2933f6eaedc21a028e146dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftllexengine-0.165.0.tar.gz:

Publisher: publish.yml on resoltico/FTLLexEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftllexengine-0.165.0-py3-none-any.whl.

File metadata

  • Download URL: ftllexengine-0.165.0-py3-none-any.whl
  • Upload date:
  • Size: 276.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ftllexengine-0.165.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adc4a8316b5a1dd0adeeff43589ba70d2e586ad87fb97f2439ed0c653e10531d
MD5 3c128aba47dd72ec2369aee6634f3ef9
BLAKE2b-256 636cf239e7f78d296ad1a8139f929d83e89710e331db5f1618ae1b513d0e8057

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftllexengine-0.165.0-py3-none-any.whl:

Publisher: publish.yml on resoltico/FTLLexEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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