Open mondeja opened 4 months ago
To get the definition site or source file of a syn::Ident
we need to pass RUSTFLAGS='--cfg procmacro2_semver_exempt'
to proc-macro2. This is not ideal because it would force all consumers of this library to pass it.
So this issue is blocked until proc_macro2::Span
implements def_site
and/or source_file
at least in nightly.
Additionally, if we could follow definitions of things, the next code can be optimized to convert from an expression to a literal:
let name = "language";
leptos_fluent! {{
...
cookie_name: name,
}}
It would be converted to:
leptos_fluent! {{
...
cookie_name: "language",
}}
AFAIK, seems possible the reading of the source code to search for the location of the fluent-templates
static_loader!
macro definition and parse its content:Because we are passing
TRANSLATIONS
toleptos_fluent!
macro, we can know where is defined. Even if is not inside the current file, altough that case could be a bit difficult.This will allow to not need to duplicate the
locales: "..."
argument and the future argumentcore_locales: "..."
(see #89).