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

Follow static_loader! definition #90

Open
mondeja opened this issue Jun 3, 2024 · 2 comments
Open

Follow static_loader! definition #90

mondeja opened this issue Jun 3, 2024 · 2 comments
Labels
blocked enhancement New feature or request

Comments

@mondeja
Copy link
Owner

mondeja commented Jun 3, 2024

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:

static_loader! {
    static TRANSLATIONS = {
        locales: "./locales",
        fallback_language: "en",
    };
}

Because we are passing TRANSLATIONS to leptos_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 argument core_locales: "..." (see #89).

@mondeja mondeja added the enhancement New feature or request label Jun 3, 2024
@mondeja mondeja changed the title Follow TRANSLATIONS static definition Follow static_loader! definition Jun 3, 2024
@mondeja
Copy link
Owner Author

mondeja commented Jun 7, 2024

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.

@mondeja mondeja added nightly Needs nightly feature blocked and removed nightly Needs nightly feature labels Jun 7, 2024
@mondeja
Copy link
Owner Author

mondeja commented Jul 29, 2024

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",
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant