Skip to content

Add templating #10

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

Merged
merged 7 commits into from
Mar 28, 2025
Merged

Add templating #10

merged 7 commits into from
Mar 28, 2025

Conversation

stifskere
Copy link
Member

@stifskere stifskere commented Mar 27, 2025

This PR closes #6, this adds translation templates by leveraging .replace() in all cases. This would leave the only case where a translation is not heap allocated when the translation does not contain templates and the macro invocation is all-static.

The only missing thing is generating a warning when x = x is used instead of x, but for that we need compile_warning!. Which isn't going to be released probably until 2026.

I'd say we can leave that commented, document and merge. Then implement it when it's implemented into the standard library.

The README is updated with the modifications this PR makes, there is no actual checking for macros as it would possibly need to change how the macro works entirely, and I believe that's also unnecessary. Escaping still works for the edge case where you have an actual parameter and you want to do something like {{x}} = {x} inside the translation for some reason.

@stifskere stifskere added this to the Library release milestone Mar 27, 2025
@stifskere stifskere requested a review from chikof March 27, 2025 19:09
@stifskere stifskere marked this pull request as ready for review March 27, 2025 22:05
@stifskere stifskere added can-be-merged The PR will be merged in the next merge cycle. assigned This PR is assigned to an issue. feature This is assigned to PRs that implement a feature. and removed enhancement labels Mar 28, 2025
@stifskere stifskere merged commit ae28fbd into main Mar 28, 2025
@stifskere stifskere deleted the feat/templating branch March 28, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned This PR is assigned to an issue. can-be-merged The PR will be merged in the next merge cycle. feature This is assigned to PRs that implement a feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translation templating
2 participants