You need to reach the $localizedresource from the root context
function translateKey(key, opts){
if(key){
const message = opts.data.root.$localizedresource[key.toUpperCase()];
return message;
}
}
Unfortunately it still gives error
It would be great if you always share the actual error detail.