protected function saveMessagesToPOT($messages, $dirName, $catalog)
{
$file = str_replace("\\", '/', "{$dirName}/{$catalog}.pot");
FileHelper::createDirectory(dirname($file));
$this->stdout("Saving messages to {$file}...\n");
$poFile = new GettextPoFile();
$merged = [];
$hasSomethingToWrite = false;
foreach ($messages as $category => $msgs) {
$msgs = array_values(array_unique($msgs));
sort($msgs);
foreach ($msgs as $message) {
$merged[$category . chr(4) . $message] = '';
}
$this->stdout("Category \"{$category}\" merged.\n");
$hasSomethingToWrite = true;
}
if ($hasSomethingToWrite) {
ksort($merged);
$poFile->save($file, $merged);
$this->stdout("Translation saved.\n", Console::FG_GREEN);
} else {
$this->stdout("Nothing to save.\n", Console::FG_GREEN);
}
}