Add Fluent based l10n/i18n functions
I saw #543 that touches on needed apparatus, but I'd like to propose a feature request that goes a step farther...
A set of localization functions used Fluent should be first class baked in tools. The ergonomics of Rust tooling for Fluent has been improving, but access from templating systems is still lacking in a number of places.
A Rust helper exists already for Rust Handlebars (cf. runtime variant, several non-handlebars Fluent templating crates). I've found that useful, but I'm now stuck using Tera for some projects and miss it sorely.
Many downstream projects would benefit from this rather than having to re-invent the wheel. For example the Zola static site generator has a long running feature request for better i18n function where I and others keep requesting Fluent access, but so far the non Fluent flat key based system they've been able to provide is lack-luster at best and flat out awkward or unworkable at worst. I think if Tera provided a basic function set it would be much easier to wire in to other projects.
Isn't that what https://docs.rs/fluent-templates/0.6.1/fluent_templates/ does?
I was unaware fluent_templates had some Tera features, I had only ever seen it in plain or Handlebars contexts.
But yes, sort of. If I was building my own Rust application it looks like that would enable me to get the job done. I guess this feature request takes on two smaller parts:
- Surface this ability from the Tera side, probably via a feature flag, such that an easy interface to that comes as a ready made set of functions rather than needing to bolt it on from the Rust side yourself.
- Enable said feature in Zola's import of Tera by default, hence exposing the functions to static site generators.
As it stands if there is a way to bolt this on to my site without needing to distribute a forked Zola to enable this I don't see what it is.
It's planned to add that crate (or something else if needed) to Zola but this shouldn't be added to Tera itself imo. It got a bit delayed in Zola but it should come during the summer, in the release after the next one.
Is fluent_templates good enough or are there issues with it that you're aware of?
The project I did using fluent_templates was quite nice to work with. The context was was pretty different but the crate is a good one. Provided that
- The
langparameter gets passed automatically from the web context to the tera function, - Resource files get loaded automatically from appropriate sources based on the lang, and
- Other context variables can be passed easily (or maybe just all of them automatically?)
...I would say that covers what I'm aware of. And sounds promising. I'll be looking forward to it. I don't know if I'll have time to contribute towards the effort but I'll try.
Any progress on this? I'm revisiting two sites I wanted to port to Zola, and this is a blocker...
None right now, got a bit side-tracked.
Roger that, fair enough, it happens. And knowing that help my planning...