Shamelessly looking at dialog code to lift, I came across WikiLove's dialog box:
$dialog = $( '\
<div id="mw-wikilove-dialog">\
<h2><html:msg key="wikilove-get-started-header"/></h2> ...
Wait, html:msg ? It calls $dialog.localize() and the whole chunk of DOM gets localized at once.