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 localization for Python
FTLLexEngine is a Python library for Fluent .ftl resources. It loads and validates Fluent
messages, formats locale-aware output, and parses localized user input back into exact Python
types.
It is designed for applications that want one locale contract for both directions:
- Format messages, currency, dates, and plural forms for 200+ locales through CLDR
- Parse localized input back into
Decimal,date,datetime, and related typed values - Validate
.ftlresources and message-variable contracts before serving traffic - Keep locale state inside
FluentBundleandFluentLocalizationinstances instead of process-global state
What It Does
Use FTLLexEngine when your application already uses Fluent for output and also needs to accept localized input such as prices, dates, or quantities.
Typical fit:
- Web services that render localized messages and need to parse localized form input correctly
- Back-office or finance systems that must avoid float drift when reading user-entered amounts
- Applications that want boot-time validation of translation resources instead of discovering
broken
.ftlfiles during a live request - Concurrent programs that need locale handling without shared mutable global state
Example: Format Output And Parse Input With The Same Locale Rules
This example formats a German quote and parses a German currency value back to exact data:
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, _ = bundle.format_pattern("quote", {"amount": Decimal("12450.00")})
# → "Angebot: 12.450,00 €" (non-breaking space before €)
parsed, _ = parse_currency("12.450,00 EUR", "de_DE", default_currency="EUR")
# → (Decimal("12450.00"), "EUR")
The same locale rules produce the outbound text and parse the inbound value. You do not need one library for formatting and a different parser for localized input.
Install
Python 3.13 or newer.
Install ftllexengine[babel] for the full runtime. This includes Fluent formatting, locale-aware parsing,
and CLDR-backed locale data. Use this option if your application formats localized output or parses
localized user input.
uv add ftllexengine[babel]
# or: pip install "ftllexengine[babel]"
Install ftllexengine without extras for the parser-only build. This includes FTL syntax support,
AST types, serialization, and validation, with no Babel dependency. Use this option if you only
need to parse, inspect, validate, or serialize Fluent resources.
uv add ftllexengine
# or: pip install ftllexengine
Documentation
- Documentation index — complete map of every Markdown document under
docs/ - Quick reference — short copy-paste recipes
- Workflow tour — end-to-end examples
- Runtime and API reference — symbol routing plus guide links
- Release protocol — release and publication workflow
- Runnable examples — executable sample programs
Legal
FTLLexEngine is MIT-licensed. The optional [babel] extra adds Babel under BSD-3-Clause.
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
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 ftllexengine-0.167.0.tar.gz.
File metadata
- Download URL: ftllexengine-0.167.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d58620961c0872f132768bacda8437e7e137175753b12b1df4640b66f84b2cf
|
|
| MD5 |
3547568d6a96108e14370c6245e05b5b
|
|
| BLAKE2b-256 |
1e52653318751731330a906bb617669848fb56bc520a7441479b6e5971da18e6
|
Provenance
The following attestation bundles were made for ftllexengine-0.167.0.tar.gz:
Publisher:
publish.yml on resoltico/FTLLexEngine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftllexengine-0.167.0.tar.gz -
Subject digest:
7d58620961c0872f132768bacda8437e7e137175753b12b1df4640b66f84b2cf - Sigstore transparency entry: 1548774002
- Sigstore integration time:
-
Permalink:
resoltico/FTLLexEngine@7c3408d02482722deaaaa1cb3f645eb5a6a38561 -
Branch / Tag:
refs/tags/v0.167.0 - Owner: https://github.com/resoltico
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c3408d02482722deaaaa1cb3f645eb5a6a38561 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ftllexengine-0.167.0-py3-none-any.whl.
File metadata
- Download URL: ftllexengine-0.167.0-py3-none-any.whl
- Upload date:
- Size: 304.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38b4e5c140c4795d7bbf771987faa6152f60c78272fed52eb2667ce310de0bf9
|
|
| MD5 |
9df9c0bbe65e36961b5f028077cf1b77
|
|
| BLAKE2b-256 |
091a508e8907706c62f366be6c5925ff5f895a9bdcd79dc721a07bdbf664defb
|
Provenance
The following attestation bundles were made for ftllexengine-0.167.0-py3-none-any.whl:
Publisher:
publish.yml on resoltico/FTLLexEngine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftllexengine-0.167.0-py3-none-any.whl -
Subject digest:
38b4e5c140c4795d7bbf771987faa6152f60c78272fed52eb2667ce310de0bf9 - Sigstore transparency entry: 1548774014
- Sigstore integration time:
-
Permalink:
resoltico/FTLLexEngine@7c3408d02482722deaaaa1cb3f645eb5a6a38561 -
Branch / Tag:
refs/tags/v0.167.0 - Owner: https://github.com/resoltico
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c3408d02482722deaaaa1cb3f645eb5a6a38561 -
Trigger Event:
push
-
Statement type: