Skip to content

feat(sprintf): Allow full sentence interpolation

Mark Florian requested to merge enhance-sprintf into master

feat(sprintf): Allow full sentence interpolation

This teaches GlSprintf to understand Start and End placeholders within a message, as is common when marking up a translatable sentence, and pass the content between those placeholders to the scoped slot of the base name of those placeholders.

This fixes the outstanding limitation of GlSprintf that string concatenation and v-html otherwise could partially (but inferiorly) solve, allowing full marked-up sentences (with arbitrary Vue components) to be translatable.

This should also preserve all existing behaviours of GlSprintf, including edge-cases, and so should be safe to upgrade to.

One recent MR where this would have been useful: gitlab!22905 (merged)

Edited by Mark Florian

Merge request reports