Open XAMPPRocky opened 12 months ago
My issue with that setup was I could not figure out how to make it work in wasm.
There is no special treatment needed for fluent-templates targetting wasm, see leptos-fluent.
I've just started using Fluent in a project, and thought of a similar way to get compile-time checking. If we generate helper functions for every message, we can also check the variables (and get autocomplete, maybe?).
For example:
# This .ftl file
issue-control-conflict-summary =
Control Input '{ $input-name }' on Processing Object '{ $po-display-name }' has conflicting inputs
issue-control-conflict-details =
Driving a Control Input with more than one signal can cause fighting.
would generate
mod tr {
use std::collections::HashMap;
use fluent::FluentValue;
use fluent_templates::Loader;
use unic_langid::LanguageIdentifier;
pub fn issue_control_conflict_summary(
lang: &LanguageIdentifier,
input_name: FluentValue<'_>,
po_display_name: FluentValue<'_>,
) -> Option<String> {
let mut args = HashMap::with_capacity(2);
args.insert("input-name", input_name);
args.insert("po-display-name", po_display_name);
super::LOCALES.try_lookup_with_args(lang, "issue-control-conflict-summary", &args)
}
pub fn issue_control_conflict_details(lang: &LanguageIdentifier) -> Option<String> {
super::LOCALES.try_lookup(lang, "issue-control-conflict-details")
}
}
I presume somebody has thought of this before, but has anybody implemented it?
Discussed in https://github.com/XAMPPRocky/fluent-templates/discussions/52