Skip to content

Compiling fluent #345

Description

@ecstrema

I couldn't find any info regarding compiling fluent to the target languages.

Is it possible, for example, to transform this:

key = Hello, {$userName}!

Into this (javascript implementation here);

key(props) => "Hello, " + props.userName + "!"

This greatly helps reducing bundle size. It is done by messageFormat and a few others and would be great to have.

Activity

  1. spookylukey commented on Feb 19, 2022

    @spookylukey
    Contributor

    For Javascript, see https://github.com/eemeli/fluent-compiler - although I have significant doubts about the implementation, as I'm not convinced it is sufficiently checking input in for the case of potentially malicious ftl files.

    For Python, there is my fluent-compiler package, although at the moment it doesn't output Python code to save for later use, it simply uses compilation as an implementation strategy.

  2. ecstrema commented on Feb 19, 2022

    @ecstrema
    Author

    Good to know. I'll have a look at both of them.

  3. eemeli commented on Feb 20, 2022

    @eemeli
    Member

    I wrote the JS compiler a while ago, but haven't touched it in years. IIRC, it might be targeting an earlier version of the Fluent spec even. I wrote it largely following on from the JS messgeformat design, i.e. as a build-time tool, so I didn't really consider malicious FTL files at all in its design.

    My current main focus around this is on the Unicode MessageFormat 2 (MF2) spec, and eventually getting that to be the basis for Intl.MessageFormat in JavaScript. This is relevant for compiling messages, as it'll include a data model representation of messages which will have native formatter support in JS as well as other languages. In other words, we'll be able to compile Fluent and other syntaxes into the MF2 data model during the application build, rather than executable JS source, and feed that to a formatter provided by the runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions