You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it would be great if there was an officially supported way to do autoformatting, preferably as a prettier plugin (see below for rationale).
while this is technically possible as a 3rd party package, that's not ideal (see below). if the current maintainers (hi @eemeli 👋🏼 i guess?) of this project are receptive to the idea (hence this issue), i may work on a pull request to this repo to add a @fluent/prettier-plugin package.
(fwiw, i locally have some hacky proof of concept code to convince myself that the things described below are actually feasible without too much maintenance effort.)
based on @fluent/syntax, which can parse + serialize, which solves all .ftl syntax technicalities
sensible defaults, no configuration
based on prettier
widely used
straight-forward implementation b/c of the plugin system and healthy ecosystem around it
many tools integrate with it
automatic support for fluent-vue b/c the prettier support for .vue files, which can contain js, html, and css… and <fluent> ftl blocks 😎, can also format embedded languages using any installed prettier plugin
strict parsing; invalid syntax causes errors. (prettier has similar behaviour for invalid javascript syntax, for example)
entries of type Message and Term sort alphabetically, with terms simply sorting between messages (e.g. example → -some-term → zzz)
fluent comments bound to messages stay bound to messages, and stand-alone comments stay in place, effectively becoming group delimiters for sortable blocks in the .ftl file.
Having good Prettier support for Fluent would be great, but having multiple such also sounds a bit concerning -- especially if/as they are liable to end up disagreeing on some parts of the formatting.
Would you and @luca-iachini be amenable on collaborating on a "canonical" plugin for Fluent? Especially with multiple maintainers I'd be happier to let it get published under the @fluent npm org.
the good news is that @fluent/syntax (part of this project) has built-in .serialize() and it handles formatting already (see source), including whitespace normalisation and comments spacing. that should settle 99% of the ‘what is the ideal format?’ debate.
(the formatting code in luca-iachini/prettier-plugin-fluent seems wholly redundant, unless it is specifically aiming for a different formatting style, but in in the fluent.js project the @fluent/syntax serialization is obviously the correct formatting, by definition.)
as i see it, the only ‘debatable’ questions are:
should entries be sorted?
my opinion: yes, always, deterministic output is good. also good for producing small diffs and reducing merge conflicts.
how should messages (message) and terms (-term) be sorted?
my opinion: terms simply sorting between messages (e.g. example → -some-term → zzz). (again, @fluent/syntax makes this trivial b/c it has Identifier.name for this already)
here are some examples. note that apart from sorting, this is just a @fluent/syntax showcase:
examples
simple messages and placeables:
example = This is an example.welcome = Welcome, {$name}, to {-brand-name}!
multi = Text can also span multiple lines as long as each new line is indented by at least one space. Because all lines in this message are indented by the same amount, all indentation will be removed from the final value.with-indents = Indentation common to all indented lines is removed from the final text value. This line has 2 spaces in front of it.
Let's hold off on jumping to a solution right away -- it's only been a few days since the discussion on this even started. As I mention in #667 (comment), we should work towards having just one Prettier plugin for Fluent.
One additional reason I'd prefer to have @luca-iachini on board with the work here is to ensure that any new code we might add to this repo will also be maintained, and that's always easier with multiple maintainers.
as i see it, a fluent prettier plugin is a very small and rather simple (sub)project.
just trying to get this sorted once and for all. i hope that @luca-iachini@timstallmann@slbls can all agree that it would be nice to have this as part of fluent.js proper. i understand y'all being busy, so if any of you read this, maybe just type ‘go ahead’ and enjoy your day 😌.
i've been involved in i18n/l10n since decades already (gnome). i already contributed to the fluent ecosystem (and tons of other OSS), e.g. improving fluent-vue docs fluent-vue/docs#8 and fluent-vue/docs#9, and getting an upstream prettier plugin is just another contribution from my side.
in the end this is just a handful lines of glue code: prettier plugin api is 20 lines of filling in the template, the actual formatting is literally two statements thanks to the @fluent/syntax parsing and serialization api (yay), and sorting the messages another 20. all of all very boring and straight-forward, a good thing!
the actual work is the rather dreadful stuff around it: build infra, testing, packaging, docs, etc. the prior art (see below) is lacking here b/c it is thankless boring work that tends to quickly evaporate b/c of various things like ecosystem, ci, package registry, etc. getting outdated. the existing packages are clearly not passion projects but quick hacks to address the need for autoformatting.
that's why i believe the fluent.js is the right home for it. shoulders of giants and so on 🙃.
also hardly maintained. https://github.com/luca-iachini/prettier-plugin-fluent/commits/main/ shows a initial burst of activity in 2024, and a short burst in 2026 which required revamping the whole build/packaging pipeline because it had gone outdated. not throwing shade, this is just how it is with many projects. (including many of my own.)
installation instructions don't work (mentions wrong package name 🙈)
Integrating this into fluent.js proper seems great! We would be very happy to no longer rely on a (very basic) plugin created primarily for internal use
no word from @luca-iachini, unfortunately. apart from pinging here on github, i also reached out over private email; full messages below for transparency.
so, what do you think of getting #668 in? i'd say it's in a good shape, definitely not a proof of concept but fully integrated into this project's build infra, docs, tooling, etc.
of course i can help out with maintenance, though the actual amount of code is just a few lines of gluing together two pretty stable APIs (prettier plugin and fluent-syntax)
thanks for your consideration!
my first email message to @luca-iachini, sent 2026-06-09
i'm trying to get the official fluent.js to include a prettier plugin. i hope you agree that would be the best place for it! would save everyone effort and unnecessary npm package maintenance pain 😅
it would be great if you could reply there and say this is a good idea, because one of the fluent.js maintainer seems to be a bit relucant b/c you also published a plugin for this.
thanks in advance! ciao!
– wouter
follow-up email message to @luca-iachini, sent 2026-06-18
hey!
it would be great to get your thumbs up on having an upstream fluent prettier plugin. see my earlier message below.
a simple ‘good idea’ in the github comment would be enough!
i wrote a dead simple formatter for my Clojure library fluent-clj which wraps fluent.js. i am very interested in an official standard format, regardless of the delivery method (plugin or function or whatever), so users of my library can match the rest of the ecosystem.
interested in an official standard format, regardless of the delivery method (plugin or function or whatever), so users of my library can match the rest of the ecosystem.
good news, @NoahTheDuke: that exists already in @fluent/syntax which can both parse and serialize with deterministic formatting, and the prettier plugin in #668 does exactly that.
(sorting is the only opinionated extra behaviour. see rationale in comment above for my opinion on sorting.)
Activity
eemeli commentedon Jun 7, 2026
Having good Prettier support for Fluent would be great, but having multiple such also sounds a bit concerning -- especially if/as they are liable to end up disagreeing on some parts of the formatting.
Would you and @luca-iachini be amenable on collaborating on a "canonical" plugin for Fluent? Especially with multiple maintainers I'd be happier to let it get published under the
@fluentnpm org.wbolster commentedon Jun 7, 2026
the good news is that
@fluent/syntax(part of this project) has built-in.serialize()and it handles formatting already (see source), including whitespace normalisation and comments spacing. that should settle 99% of the ‘what is the ideal format?’ debate.(the formatting code in luca-iachini/prettier-plugin-fluent seems wholly redundant, unless it is specifically aiming for a different formatting style, but in in the
fluent.jsproject the@fluent/syntaxserialization is obviously the correct formatting, by definition.)as i see it, the only ‘debatable’ questions are:
should entries be sorted?
how should messages (
message) and terms (-term) be sorted?example→-some-term→zzz). (again,@fluent/syntaxmakes this trivial b/c it hasIdentifier.namefor this already)here are some examples. note that apart from sorting, this is just a
@fluent/syntaxshowcase:examples
simple messages and placeables:
multiline message (based on the fluent guide):
sorting:
variants and attributes:
Add @fluent/prettier-plugin package to autoformat Fluent resources
Add @fluent/prettier-plugin package to autoformat Fluent resources
Add @fluent/prettier-plugin package to autoformat Fluent resources
wbolster commentedon Jun 9, 2026
quoting @eemeli in #668:
as i see it, a fluent prettier plugin is a very small and rather simple (sub)project.
just trying to get this sorted once and for all. i hope that @luca-iachini @timstallmann @slbls can all agree that it would be nice to have this as part of
fluent.jsproper. i understand y'all being busy, so if any of you read this, maybe just type ‘go ahead’ and enjoy your day 😌.i've been involved in i18n/l10n since decades already (gnome). i already contributed to the fluent ecosystem (and tons of other OSS), e.g. improving fluent-vue docs fluent-vue/docs#8 and fluent-vue/docs#9, and getting an upstream prettier plugin is just another contribution from my side.
in the end this is just a handful lines of glue code: prettier plugin api is 20 lines of filling in the template, the actual formatting is literally two statements thanks to the
@fluent/syntaxparsing and serialization api (yay), and sorting the messages another 20. all of all very boring and straight-forward, a good thing!the actual work is the rather dreadful stuff around it: build infra, testing, packaging, docs, etc. the prior art (see below) is lacking here b/c it is thankless boring work that tends to quickly evaporate b/c of various things like ecosystem, ci, package registry, etc. getting outdated. the existing packages are clearly not passion projects but quick hacks to address the need for autoformatting.
that's why i believe the
fluent.jsis the right home for it. shoulders of giants and so on 🙃.prior art 1: desmosinc
prior art 2: luca-iachini
@fluent/syntaxfor serialization for unclear reasons. maybe not aware of that existing at all? the docs mention it but not prominently. 😬timstallmann commentedon Jun 9, 2026
Integrating this into
fluent.jsproper seems great! We would be very happy to no longer rely on a (very basic) plugin created primarily for internal usewbolster commentedon Jun 29, 2026
hey @eemeli 👋🏼, earlier you seemed a bit worried that i was going a bit too fast when i opened this
@fluent/prettier-pluginpull request.it's been 3 weeks now, and i'd really like this to move ahead.
regarding the existing two projects, both of which are not actively maintained (see my earlier message):
@timstallmann (maintainer of the
demosincprior art) likes the ideano word from @luca-iachini, unfortunately. apart from pinging here on github, i also reached out over private email; full messages below for transparency.
so, what do you think of getting #668 in? i'd say it's in a good shape, definitely not a proof of concept but fully integrated into this project's build infra, docs, tooling, etc.
of course i can help out with maintenance, though the actual amount of code is just a few lines of gluing together two pretty stable APIs (prettier plugin and
fluent-syntax)thanks for your consideration!
my first email message to @luca-iachini, sent 2026-06-09
follow-up email message to @luca-iachini, sent 2026-06-18
NoahTheDuke commentedon Jun 29, 2026
i wrote a dead simple formatter for my Clojure library fluent-clj which wraps fluent.js. i am very interested in an official standard format, regardless of the delivery method (plugin or function or whatever), so users of my library can match the rest of the ecosystem.
wbolster commentedon Jun 29, 2026
good news, @NoahTheDuke: that exists already in
@fluent/syntaxwhich can both parse and serialize with deterministic formatting, and the prettier plugin in #668 does exactly that.(sorting is the only opinionated extra behaviour. see rationale in comment above for my opinion on sorting.)
wbolster commentedon Jul 15, 2026
gentle ping @eemeli 👋🏼. can i help move this forward somehow?
Add @fluent/prettier-plugin package to autoformat Fluent resources