hi 👋🏼,
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.)
what i would love to see:
- part of the projectfluent/fluent.js set of JS libraries
- 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.
prior art:
thoughts welcome!
hi 👋🏼,
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-pluginpackage.(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.)
what i would love to see:
@fluent/syntax, which can parse + serialize, which solves all.ftlsyntax technicalities.vuefiles, which can contain js, html, and css… and<fluent>ftl blocks 😎, can also format embedded languages using any installed prettier pluginMessageandTermsort alphabetically, with terms simply sorting between messages (e.g.example→-some-term→zzz).ftlfile.prior art:
https://github.com/luca-iachini/prettier-plugin-fluent (hi @luca-iachini 👋🏼)
@fluent/syntaxalso does thathttps://github.com/desmosinc/prettier-plugin-fluent by (hi @timstallmann @slbls 👋🏼)
thoughts welcome!