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

Consider a code generation type safe version of i18n-embed-fl #73

Open
kellpossible opened this issue Oct 24, 2021 · 3 comments
Open

Consider a code generation type safe version of i18n-embed-fl #73

kellpossible opened this issue Oct 24, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@kellpossible
Copy link
Owner

The https://github.com/baptiste0928/rosetta project brings some interesting ideas, it generates code using the build.rs script that can be used to reference localizations using native Rust types which also integrates well with IDE autocomplete. In addition, the function signature for localizations with variables are also generated, making it very easy to use a given localization correctly without needing to reference the source file. Seems like it should be possible to do something similar with fluent.

@kellpossible kellpossible added the enhancement New feature or request label Oct 24, 2021
@kellpossible
Copy link
Owner Author

Perhaps this could be made into an optional feature/technique until it proves itself on some larger projects/examples.

@kellpossible
Copy link
Owner Author

This may rely on some ideas in #31 to be completely valid.

i18n::SOME_KEY.fmt(loader, arg1, arg2);
i18n::SOME_KEY.ATTRIBUTE.fmt(loader);

This does however lose some of the readability of the named arguments in i18n-embed-fl implementation.

@kellpossible
Copy link
Owner Author

Alternatively, messages can be functions which is what https://github.com/zaytsev/fluent-static seems to do, which seems like a much better idea.

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

No branches or pull requests

1 participant