public function selectLanguage($langcode = null)
    {
        $languages = array();

        foreach ($this->language->getList() as $code => $language) {
            if ($code === 'en' || is_file($this->translation->getFile($code))) {
                $languages[$code] = $language['name'];
            }
        }

        if (count($languages) < 2 && !isset($langcode)) {
            return null;
        }

        if (isset($langcode)) {
            $selected = $langcode;
        } else {
            $selected = $this->menu($languages, 'en', $this->text('Language (enter a number)'));
        }

        if (empty($languages[$selected])) {
            $this->error($this->text('Invalid language'));
            $this->selectLanguage();
        } else {
            $this->langcode = (string) $selected;
            $this->translation->set($this->langcode, null);
            $this->config->set('cli_langcode', $this->langcode);
        }

        return $this->langcode;
    }