Fluent Runtime is the Python implementation of Project Fluent's runtime component, providing localization capabilities for expressive translations. It handles parsing and formatting of Fluent Localization (FTL) files. The current version is 0.4.0, with new releases occurring infrequently, often in conjunction with updates to the `fluent.syntax` library.
pip install fluent-runtimeVerified import paths — ran on the pinned version, not inferred.
Initializes `FluentResource` objects from FTL strings, then creates `FluentBundle` objects for specific locales. `FluentLocalization` acts as the high-level manager, providing an easy way to switch locales and format messages using `format_value`.
Upgrade your Python environment to 3.6 or newer.
Replace `bundle.add_messages(msgs)` with `bundle.add_resource(FluentResource(msgs))` and update direct `bundle.format()` calls with `bundle.format_pattern(bundle.get_message(message_id).value, args)` or use the higher-level `FluentLocalization.format_value` method.
Installing `fluent-runtime` via pip will automatically pull in a compatible `fluent.syntax` version. If managing dependencies manually, ensure `fluent.syntax>=0.19,<0.20` is installed alongside `fluent-runtime 0.4.x`.
Migrate direct `FluentBundle` instantiation and usage to `FluentLocalization` for managing multiple bundles and locale resolution in complex applications.
Ensure that the FTL file contains a message with the exact ID 'your-message-id' and that the Fluent resources are loaded correctly by `FluentLocalization` or `FluentBundle`.
Install the library using pip: `pip install fluent-runtime`.
Review your FTL files for typos, missing characters (like closing braces), or incorrect Fluent syntax, especially around the indicated line or character position if available in the full traceback.
Change the import statement to `from fluent.runtime import FluentLocalization`.