String substitution in localisation (messageResources)

13 views
Skip to first unread message

Colin Bester

unread,
Apr 21, 2017, 9:17:26 AM4/21/17
to Lift
I know one is able to use string substitution by defining variable like:

label.device.status = Device %s Status in messageResources and then passing the parameter in using S....


Is the same possible when using <span class="lift:loc?locid=label.device.status"> in html file?


Thanks




Antonio Salazar Cardozo

unread,
Apr 22, 2017, 8:28:18 AM4/22/17
to Lift
Hey Colin,
You can't use it directly with the Loc snippet, no. Generally in these cases I bind it in my own snippet. This has the added advantage that typically in these cases I find the parameter that I'm passing is most understandable in the context of that snippet.

That said, if you need that functionality, you can always write a version of the Loc snippet that does what you want it to for your project. We have a version that allows us to fluently set attributes (we use data attributes to carry JS-bound i18n content sometimes) or even an attribute and a body (for when we need to set a title for a tooltip + put ellipsis client-side on an element.

If you can explain the use case and it seems general enough, you could even consider contributing such an improvement to Lift ;)
Thanks,
Antonio

Colin Bester

unread,
Apr 23, 2017, 7:25:55 PM4/23/17
to Lift
Thanks Antonio, it just seemed convenient but I think I am going to go the snippet route.

Appreciate the response.

Colin

Antonio Salazar Cardozo

unread,
Apr 23, 2017, 8:48:51 PM4/23/17
to Lift
My pleasure!
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages