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

Allow variables for keys #262

Open
johansmitsnl opened this issue Dec 9, 2024 · 2 comments
Open

Allow variables for keys #262

johansmitsnl opened this issue Dec 9, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@johansmitsnl
Copy link

I have a backend that returns errors with a translation key. These errors are not translated because the UI sometimes needs to make changes to certain explanations that the backend is unaware of.

I face 2 issues:

  1. Adding the translations makes the check_translations panic because keys are not used in the code
  2. When trying to use the translation key as the input the macro panics.

Example of point 2:

let backend_key = "error-backend";

move_tr!(backend_key);

How can I solve this?

@mondeja mondeja added the enhancement New feature or request label Dec 16, 2024
@mondeja
Copy link
Owner

mondeja commented Dec 16, 2024

  1. Adding the translations makes the check_translations panic because keys are not used in the code

You can put these translations in a file that is not added to check_translations glob.

  1. When trying to use the translation key as the input the macro panics.

This is not currently implemented in leptos-fluent. The idea is to follow the definitions of variables passed to tr! macros after parsing definitions with literals, to make check_translations work with them. It should be a bit tricky because variables can be used from other files. PRs welcome.

@johansmitsnl
Copy link
Author

The 1st is indeed a smart option.

I'll check if I'm able to create a pr.

@mondeja mondeja added the help wanted Extra attention is needed label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants