I'm adding language support to my first plugin, and I have some questions as to how to do that correctly. What I need is one string (configurable), to be used by a custom function. So I put the following in my plugin's languages.yaml file:
en:
PLUGIN_ANTISPAM:
NOSCRIPT: [email address is javascript encrypted]
de:
PLUGIN_ANTISPAM:
NOSCRIPT: [Mailadresse ist Javascript-verschlüsselt]
And in my custom function, I tried to read this with the following:
function munge($array) {
// a bunch of irrelevant stuff here
$txt .= "<noscript>".$grav['language']->translate(['PLUGIN_ANTISPAM.NOSCRIPT'])."<"."/noscript>";
return $txt;
}
I got this from the documents. However, this returns a Crikey! error that says "Undefined variable: grav". What is wrong?