Closed
Description
Edit: It appeared that the fluent.runtime
I installed with pip install fluent.runtime
was actually a lot older than what I expected.
When adding messages to Fluent bundles, the documentation at https://fluent-runtime.readthedocs.io/en/latest/index.html states you can directly add the messages as a template string like so:
>>> bundle.add_messages("""
... welcome = Welcome to this great app!
... greet-by-name = Hello, { $name }!
... """)
In reality, you have to wrap the template string into a FluentResource
and use bundle.add_resource
instead of bundle.add_messages
because it does not exist. The add_resource
function checks if there is a body
key in the resource
function parameter, which is generated by the FluentResource
class.
from fluent.runtime import FluentBundle, FluentResource
bundle = FluentBundle(['en-us'])
bundle.add_resource(FluentResource("""
welcome = Welcome!
"""))
Also, bundle.format()
does not exist.
Metadata
Metadata
Assignees
Labels
No labels