Open mgautierfr opened 2 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
@veloman-yunkan Have you used this approach in your latest il8n PRs? Or this is still on the todo list?
@kelson42 I have not used this approach yet. It's not even on my todo list. There can be other approaches for the root problem at hand. I will work in that direction when the need for it becomes more apparent.
Following #679
The current implementation of i18n use templating a two level :
This is somehow complicated (Where should we use
{{}}
or{{{}}}
? Cpp code need to know that we use translated message and translate it before rendering the template, ...)As mustache allow the using of lambda to compute text at runtime, we could use this to have HTML templates directly using the parameterized key. (lambda feature, lambda rendering)
If we create a "translator" lambda (called
t
), we could write templates this way :[blabla] title="{{#t}}searchbox-tooltip BOOK_TITLE={{title}}{{/t}}" aria-label="{{#t}}searchbox-tooltip BOOK_TITLE={{title}}{{/t}}">
We would have to write a custom parser for the
BOOK_TITLE=...
parameters but it will simplify the cpp code as it will move "all" the templating in the template and avoid us to pre-render in cpp the translated text for the template.