Function generates translation for specified language

@param Language $language language of translation

@return array
559746
private function generateContentTranslation(Language $language)
    {
        $faker = Factory::create($language->i18n);
        return [
            'teaser'          => '<p>' . $faker->realText(300) . '</p>',
            'body'            => $this->generateBodyHTML($faker),
            'seo_title'       => $faker->realText(60, 1),
            'seo_description' => $faker->realText(160, 1)
        ];
    }
325199
private function getTranslations($lang) {
    if (!isset($this->translations[$lang])) {
      $messageFile = $this->localeDir."/messages_".$lang.".php";
      if (file_exists($messageFile)) {
        require_once($messageFile);
        // store for later reference
        $this->translations[$lang] = ${"messages_$lang"};
      }
      else {
        $this->translations[$lang] = [];
      }
    }
    return $this->translations[$lang];
  }
767947
protected static function languageSpecificCharsArray($language)
    {
        static $languageSpecific;

        if (! isset($languageSpecific)) {
            $languageSpecific = [
                'bg' => [
                    ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'],
                    ['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'],
                ],
                'da' => [
                    ['æ', 'ø', 'å', 'Æ', 'Ø', 'Å'],
                    ['ae', 'oe', 'aa', 'Ae', 'Oe', 'Aa'],
                ],
                'de' => [
                    ['ä',  'ö',  'ü',  'Ä',  'Ö',  'Ü'],
                    ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'],
                ],
                'ro' => [
                    ['ă', 'â', 'î', 'ș', 'ț', 'Ă', 'Â', 'Î', 'Ș', 'Ț'],
                    ['a', 'a', 'i', 's', 't', 'A', 'A', 'I', 'S', 'T'],
                ],
            ];
        }

        return $languageSpecific[$language] ?? null;
    }
530402
protected function getAllTxFiles($language)
    {
        $iterator = new \DirectoryIterator($this->txlang . DIRECTORY_SEPARATOR . $language);

        $files = array();
        while ($iterator->valid()) {
            if (!$iterator->isDot()
                && $iterator->isFile()
                && $iterator->getExtension() == 'xlf'
                && $this->isNotFileToSkip($iterator->getPathname())
            ) {
                $files[$iterator->getPathname()] = $iterator->getFilename();
            }
            $iterator->next();
        }

        return $files;
    }
488760
public function getTranslation($language = null)
    {
        $language = $language ?: Yii::$app->language;
        $translations = $this->getModelTranslations();

        // search translation by language in exists translations
        foreach ($translations as $translation) {
            // if translation exists - return it
            if ($translation->getAttribute($this->translationLanguageAttrName) === $language) {
                $this->translationsBuffer[] = $translation;

                return $translation;
            }
        }

        // if translation doesn't exist - create and return
        $translationEntityClass = $this->owner->getRelation($this->translationRelationName)->modelClass;

        /* @var BaseActiveRecord $translation */
        $translation = new $translationEntityClass();
        $translation->setAttribute($this->translationLanguageAttrName, $language);
        $translations[] = $translation;
        $this->translationsBuffer = $translations;
        $this->owner->populateRelation($this->translationRelationName, $translations);

        return $translation;
    }
397163
private function loadTranslations($language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

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

        if (isset($this->files[$language])) {
            foreach ($this->files[$language] as $file) {
                if (is_file($file)) {
                    $this->translations[$language] = array_merge(
                        $this->translations[$language],
                        $this->getTranslationArrayFromFile($file)
                    );
                } elseif (is_dir($file)) {
                    $it = new \RecursiveDirectoryIterator($file, \FilesystemIterator::SKIP_DOTS);
                    $it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);

                    foreach ($it as $file) {
                        if (is_file($file->getRealPath())) {
                            $this->translations[$language] = array_merge(
                                $this->translations[$language],
                                $this->getTranslationArrayFromFile($file->getRealPath()));
                        }
                    }
                }
            }
        }
    }
1368965
public function loadAllTranslations($language)
    {
        foreach ($this->loaded as $module) {
            $this->loadModuleTranslation($module, $language);
        }
    }
1106182
public function updateLanguage(Language $language)
    {
        $query = $this->dbHandler->createUpdateQuery();
        $query->update($this->dbHandler->quoteTable('ezcontent_language'));

        $this->setCommonLanguageColumns($query, $language);

        $query->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('id'),
                $query->bindValue($language->id, null, \PDO::PARAM_INT)
            )
        );

        $query->prepare()->execute();
    }
622816
public function generateElements($language = null)
    {
        $sitemapElements = [];
        $transformer = $this->transformer;

        $entities = $this
            ->entitySitemapElementProvider
            ->getEntities();

        if (is_array($entities)) {
            foreach ($entities as $entity) {
                $sitemapElements[] = $this
                    ->sitemapElementFactory
                    ->create(
                        $transformer->getLoc($entity, $language),
                        $transformer->getLastMod($entity, $language),
                        $this->changeFrequency,
                        $this->priority
                    );
            }
        }

        return $sitemapElements;
    }
625970
public function getAllTranslationByLanguage()
    {
        $messages = array();
        foreach ($this->getLanguageList() as $language) {
            $messages[$language] = $this->getTranslationsForLanguage($language);
        }

        return $messages;
    }
683038
public function getMetadata($language)
	{
		$path = $this->getLanguagePath(ANPATH_BASE, $language);
		$file = $language.'.json';

		$meta = null;

		if (file_exists($path.DS.$file)) {
			$result = json_decode(file_get_contents($path.DS.$file));
			$meta = $result->meta;
			$meta->tag = $result->tag;
		}

		return $meta;
	}
919751
public static function setLanguage($language)
    {
        if (! ($language instanceof Language)) {
            $language = Language::findByCode($language);
        }

        if (! $language) {
            return false;
        }

        App::setLocale($language->code);
        request()->setDefaultLocale($language->code);
        self::$language = $language;

        return $language;
    }
147434
public function getLanguage($language)
    {
        if (!$this->getLanguages()->has($language)) {
            $this->getLanguages()->set($language, new LanguageBag());
        }

        return $this->getLanguages()->get($language);
    }
133205
public function setTranslationsForLanguage(array $messages, $language)
    {
        foreach ($messages as $key => $value) {
            $this->setTranslation($key, $value, $language);
        }
    }
63439
public function getAllMessages($language = null) {
	
		$this->loadAllMessages();

		// The array of messages by message, then by language:
		// array(message_key => array(language => message))
		$msgs = array();
	
		$keys = $this->getAllKeys();
	
		$languages = $this->getSupportedLanguages();
	
		foreach ($keys as $key) {
			$msgs[$key] = $this->getMessageForAllLanguages($key, $language);
		}
	
		ksort($msgs);
		$response = array("languages"=>$languages, "msgs"=>$msgs);
		return $response;
	}
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)];
    }
67676
public function addTranslationArray(array $translations, $language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

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

        $this->translations[$language] = array_merge(
            $this->translations[$language],
            $translations
        );
    }