2007/9/26, Robin Elfrink <[EMAIL PROTECTED]>:
> this.get_label() does not know about variable substitutions. How's the
> attached patch?
Right. I thought we'll implement it when needed...
> +
> + if (vars && vars.constructor.toString().indexOf('Array')>=0)
> + for (var i=0; i<vars.length; i++)
> + label = label.replace(/%s/, vars[i]);
> +
I would like to use the same "syntax" as in PHP. This allows us to use
the same labels in both PHP and Javascript. The replacement of
$varname in the label string could look like this:
if (vars && typeof vars == 'object')
for (var key in vars)
label = label.replace(new RegExp('\$'+key, 'g'), vars[key]);
and then use it with...
var foo = this.get_label('mylabel', {myvar:"Yeah!"});
~Thomas
P.S. The above code is untested.
_______________________________________________
List info: http://lists.roundcube.net/dev/