fluent_compiler.resource

class fluent_compiler.resource.FtlResource(text, filename=None)[source]

Represents the contents and (optional) name of a FTL resource e.g. a messages.ftl file. If you are using FluentBundle you can often avoid using this directly by using the convenience methods on that class.

The filename is optional and used only for error messages. You could use any convenient identifier (e.g. a URL). Without this identifier, however, it may be hard to locate the source of any generated errors - you will get a line and column number, but not a filename!

There are two convenience constructors:

classmethod from_string(text)[source]

Create an FtlResource from FTL source text.

classmethod from_file(filename, encoding='utf-8')[source]

Create an FtlResource from a filename, by opening and reading the file. UTF-8 encoding is assumed, but can be overridden.