protected function saveMessagesToPOT($messages, $dirName, $catalog)
    {
        $file = str_replace('\\', '/', "$dirName/$catalog.pot");
        FileHelper::createDirectory(dirname($file), $this->filesystemMode);
        $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) {
            return new Promise(function($r, $c) use ($poFile, $merged, $file) {
                ksort($merged);
                $poFile->save($merged, $file);
                $this->stdout("Translation saved.\n", Console::FG_GREEN);
                return true;
            });
        } else {
            $this->stdout("Nothing to save.\n", Console::FG_GREEN);
            return resolve(true);
        }
    }