Yii::t() isn’t designed for this use case. Create another translation function to handle this case, I put mine in controller and did $this->t(). Based on Qiang’s feedback when I put this in the bug system.
Thanks Say_Ten. I tried that and it got a bit further but it was still falling over with invalid filename. So I changed MessageCommand.php and added the following code at the top of protected function generateMessageFile
$fn= preg_split("/[\s,\']+/", $fileName);
$fileName=$fn[0];
echo "Saving messages to $fileName...";
Also, although there is a loop for languages, there is no code to explode this from the input parameters. So I added this to the main run function just before the language loop
$languages=explode(",", $languages["0"]);
Note: that languages was an array but contained the list of languages unexploded!