What is the most functional CLI option for using Fluent?

I’m looking for a CLI to interact with Fluent translations. The primary thing I want to do is query an *.ftl file for a specific message. I expect to provide the message id and any contextual data required as command line arguments and get a translated string back.

I had a look at the Rust repository and see a CLI folder, but the link in the README to a crate for it is dead, and I don’t see anything in the main crate about it either. I’m not familiar enough with the Rust ecosystem to even know what I’m expected to do with that folder — if indeed it’s not just a placeholder and there is something there that can be used.

Poking at both Python and Javascript it doesn’t look like it would be too hard to build my own wrapper CLI script to make them produce such results, but I have to assume this work has been done before and I’m just not finding it.

Hmmm, at least partially answering my own question — the Rust implementation does seem to have a working CLI, it just isn’t obvious how to get there. Even running cargo build in the CLI folder doesn’t produce anything. At least not there. But building the whole project at the top level does produce two binaries at target/debug/{parser,resorver}. Passing parser the name of at FTL file does spit out a parsed AST representation, so that’s something.

It’s less obvious to me how to use resolver. It expects something STDIN, but with no help messages or documentation it’s not clear to me what. It crashes if I give it a string, raw FTL content, or the output of parser.

resolver is part of the cross-implementation resolver test suite that Zibi prototyped in the Rust implementation. It’s taking Fluent content from stdin, and then resolves the test message. It’s not intended to be used in other ways.

What’s your use case? As in, this is the first time I hear a request for a cli.

We commonly toy around with Fluent syntax ourselves, of course, but we’re using https://projectfluent.org/play/ for that. That renders each message in the given Fluent content.

Axel

That explains why I couldn’t make resolver do anything!

I would have several use cases actually. One of them of course is a quick way to compare the output of my own Lua implementation but beyond that…

I have a number of projects (multi-lingual publishing company & online academy) that are built by cobbling together lots of different CLI tools. Content from the projects gets passed through lots of different stages, many of which will never have a built in Fluent implementation. One example would be POV-Ray. I have localized content that gets passed into a POV source file. Considering how little POV even does with strings internally it isn’t going to get FTL support. But I am already pre-processing the *.pov files and could easily pass in the correct strings. But to do that I need to lookup what the correct strings are in a shell script.

Other uses come to mind to, but in thinking about this I’ve actually come to the conclusion that probably all of the implementations should add CLI support. Rust makes the most sense as a stand-alone tool, but for projects which already use Python or Javascript using the respective package managers would make an easy way to get CLI support local to a project and ease developers’ lives.