Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django javascript translation with simple interpolation

The documentation for javascript translation in django only gives examples of pluralised interpolation. I want to do something simple like below:

var format = gettext("Displaying %(count)s / %(total)s")
var text = interpolate(format, {"count": 5, "total": 10})

which should set text to Displaying 5 / 10

But this isn't working for me. I get Displaying %(count)s / %(total)s as the value for for text.

Does anyone know how to do this simple sort of interpolation?

like image 825
iancoleman Avatar asked Jul 11 '12 06:07

iancoleman


1 Answers

You're missing true argument:

var text = interpolate(format, {"count": 5, "total": 10}, true);
like image 55
freakish Avatar answered Nov 05 '22 06:11

freakish