protected function determineLanguages(OutputInterface $output, $srcdir, $filter = array())
    {
        if (!is_dir($srcdir)) {
            throw new \InvalidArgumentException(sprintf('The path %s does not exist.', $srcdir));
        }

        $this->writelnVerbose($output, sprintf('<info>scanning for languages in: %s</info>', $srcdir));
        $matches  = array();
        $iterator = new \DirectoryIterator($srcdir);
        do {
            $item = $iterator->getFilename();

            if ((!$iterator->isDot()) && (strlen($item) == 2) && ((!$filter) || in_array($item, $filter))) {
                $matches[] = $item;
                $this->writelnVerbose($output, sprintf('<info>using: %s</info>', $item));
            } elseif (!$iterator->isDot()) {
                $this->writelnVerbose($output, sprintf('<info>not using: %s</info>', $item));
            }
            $iterator->next();
        } while ($iterator->valid());

        $this->languages = $matches;
    }