Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fluent based l10n/i18n functions #646

Open
alerque opened this issue Jun 30, 2021 · 7 comments
Open

Add Fluent based l10n/i18n functions #646

alerque opened this issue Jun 30, 2021 · 7 comments

Comments

@alerque
Copy link

alerque commented Jun 30, 2021

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.

@Keats
Copy link
Owner

Keats commented Jun 30, 2021

Isn't that what https://docs.rs/fluent-templates/0.6.1/fluent_templates/ does?

@alerque
Copy link
Author

alerque commented Jun 30, 2021

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:

  1. 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.
  2. 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.

@alerque alerque changed the title Add Fluent basied l10n functions Add Fluent based l10n/i18n functions Jun 30, 2021
@Keats
Copy link
Owner

Keats commented Jul 1, 2021

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?

@alerque
Copy link
Author

alerque commented Jul 1, 2021

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 lang parameter 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.

@alerque
Copy link
Author

alerque commented Jun 24, 2022

Any progress on this? I'm revisiting two sites I wanted to port to Zola, and this is a blocker...

@Keats
Copy link
Owner

Keats commented Jun 26, 2022

None right now, got a bit side-tracked.

@alerque
Copy link
Author

alerque commented Jun 27, 2022

Roger that, fair enough, it happens. And knowing that help my planning...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@alerque @Keats and others