I am using Mustache's Lambda's to implement translations in my templates.
My templates use these kind of tags:
<h1>{{#t}}Some translatable text{{/t}}</h1>
then, in my data I register a lambda to fetch the translation:
$info['t'] = function($text, $render) {
return translate($text);
}
However, I would like to be able to set the locale in that lambda, but I don't seem to get it right:
$locale = "nl_NL";
$info['t'] = function($text, $render, $locale) {
return translate($text, $locale);
}
doesn't work (obviously) because Mustache calls this lambda with two parameters. Trying with a default parameter doesn't work either:
$lc = "nl_NL";
$info['t'] = function($text, $render, $locale = $lc) {
return translate($text, $locale);
}
Because you cannot use a variable as default.
How can I get this working?