@param string|null $language optional language code to search for

@return string
188441
public function description(string $language = null): ?string
    {
        if ($language === null) {
            return array_get($this->translation, 'description');
        }

        $translation = array_first($this->translations, function ($translation) use ($language) {
            return $translation['language_code'] === $language;
        });

        return array_get($translation, 'description');
    }
396536
public function joinLang($language = null)
    {
        if (!$language) {
            if (Yii::$app->id === 'app-backend') {
                $language = Yii::$app->wavecms->editedLanguage;
            } else {
                $language = Yii::$app->language;
            }
        }

        return $this->leftJoin(PageLang::tableName(),
            PageLang::tableName() . '.page_id = ' . Page::tableName() . '.id AND 
                ' . PageLang::tableName() . '.language = "' . $language . '"');
    }
137548
public function getSpecialTid($language, $key)
    {
        $languageSpecialTids = $this->getSpecialTidsForLanguage($language);

        if (!empty($languageSpecialTids[$key])) {
            return $languageSpecialTids[$key];
        }

        return null;
    }
310420
public function language($language = null) {
		$this->getRequest()->allowMethod(['post']);

		$allowedLanguages = (array)Configure::read('Config.allowedLanguages');
		if (!$language) {
			$language = Configure::read('Config.defaultLanguage');
		}
		if (!$language) {
			$keys = array_keys($allowedLanguages);
			$language = $allowedLanguages[array_shift($keys)];
		}

		if (!array_key_exists($language, $allowedLanguages)) {
			throw new RuntimeException('Invalid Language');
		}
		$language = $allowedLanguages[$language];

		$this->getRequest()->getSession()->write('Config.language', $language['locale']);
		I18n::setLocale($language['locale']);
		$this->Flash->success(__d('tools', 'Language switched to {0}', $language['name']));
		return $this->redirect($this->referer('/', true));
	}
1107840
public function getNodeTranslationsQueryBuilder($lang = null)
    {
        $queryBuilder = $this->createQueryBuilder('nt')
            ->select('nt,n,v')
            ->innerJoin('nt.node', 'n')
            ->leftJoin(
                'nt.publicNodeVersion',
                'v',
                'WITH',
                'nt.publicNodeVersion = v.id'
            )
            ->where('n.deleted = false')
            ->orderBy('nt.weight')
            ->addOrderBy('nt.weight');

        if (!empty($lang)) {
            $queryBuilder
                ->andWhere('nt.lang = :lang')
                ->setParameter('lang', $lang);
        }

        return $queryBuilder;
    }
1156332
public function getKeyword($language = null)
    {
        if (empty($language)) {
            $language = $this->mainLanguageCode;
        }

        if (!is_array($this->keywords) || !array_key_exists($language, $this->keywords)) {
            return null;
        }

        return $this->keywords[$language];
    }
450922
public static function filterLanguage($value)
    {
        $uri = self::getExistingLanguageUri($value);
        /** @noinspection NullPointerExceptionInspection */
        return $uri !== null
            ? $uri
            : self::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri();
    }
563830
protected function getMessageFilePath($language)
    {
        $messageFile = $this->aliases->get($this->basePath) . '/' . $language . '/' . $this->catalog;
        if ($this->useMoFile) {
            $messageFile .= self::MO_FILE_EXT;
        } else {
            $messageFile .= self::PO_FILE_EXT;
        }

        return $messageFile;
    }
165737
public function langset($lang = null)
    {
        if (!is_null($lang)) {
            $this->langset = $lang;
            return $this;
        } else {
            return $this->langset ?: '';
        }
    }
630483
public function getName($languageCode = null)
    {
        if ($languageCode === null) {
            $languageCode = $this->initialLanguageCode;
        }

        return $this->names[$languageCode];
    }
254129
private static function getMessagesByLanguage($language)
    {
        $messages = [];

        if (!array_key_exists($language, self::$messages)) {
            self::tryLoadingMessageFile($language);
        }

        if (array_key_exists($language, self::$messages)) {
            $messages = self::$messages[$language];
        } else {
            self::tryLoadingMessageFile('en');
            if (array_key_exists('en', self::$messages)) {
                $messages = self::$messages['en'];
            }
        }

        return $messages;
    }
975028
public function getTranslation($language = null)
    {
        if ($language === null) {
            $language = $this->getLanguage();
        }

        if (!isset($this->_models[$language])) {
            $this->_models[$language] = $this->loadTranslation($language);
        }

        return $this->_models[$language];
    }
674357
private function getPosixLocale(Language $language): ?array
    {
        if (!$language->enabled) {
            return null;
        }

        $posixLocale = $this->localeConverter->convertToPOSIX($language->languageCode);
        if ($posixLocale === null) {
            return null;
        }

        if (!Locales::exists($posixLocale)) {
            return null;
        }

        return [$posixLocale, Locales::getName($posixLocale)];
    }
46439
public function getTranslation($language = null)
    {
        $language = $language ?: $this->_currentLanguage;
        return $this->owner->hasOne($this->translationClassName, [$this->languageForeignKey => $this->_ownerPrimaryKey])
                        ->where([$this->languageField => $language]);
    }
664311
public function getTranslationsForLanguage($language) {
		if (!isset($this->messages[$language])) {
			$messageLanguage = $this->getMessageFile($language);
			$this->messages[$language] = $messageLanguage->getAllMessages();
		}		
		return $this->messages[$language];
	}
670264
public static function validateLanguageCode(string $languageCode = null): string
    {
        // We allow empty languageCode in order to quit asking for more
        if (empty($languageCode)) {
            return '';
        }

        if (!preg_match('/^[a-z][a-z][a-z]-[A-Z][A-Z]$/', $languageCode)) {
            throw new InvalidArgumentException('Language code name is not valid.');
        }

        return $languageCode;
    }
383676
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;
    }