Validates and returns list of languages.

@param array $languages
@param \yii\base\Object $owner
@return array
@throws InvalidConfigException
323883
public static function getLanguages($languages, $owner)
    {
        if (!$languages && isset(Yii::$app->params['languages'])) {
            $languages = Yii::$app->params['languages'];
        }

        if (!is_array($languages) || empty($languages)) {
            throw new InvalidConfigException('Please specify array of available languages in the '
            . get_class($owner) . ' or in the application parameters');
        }

        return $languages;
    }
270909
private function getValue(array $values, $languages, $group, $parent = NULL)
    {
    	foreach($values as $key => $value){

			foreach($languages as $language){
				$entry = Translation::firstOrCreate([
					'key' => $key,
					'language' => $language,
					'translation_group' => $group->id,
					'parent' => $parent
				]);
				if(is_array($value)){
					$this->getValue($value, $languages, $group, $entry->id);
				} else {
					if($entry->value === NULL){
						$entry->value = $value;
						$entry->save();
					}
				}
			}
	    }
    }
417819
protected function serializeHasMany(Model $owner, array $models = null, AdapterInterface $adapter)
    {
        if (empty($models)) {
            return $this->serialize(null, $adapter);
        }
        return $this->serializeArray($models, $adapter);
    }
1021056
public function loadLanguages()
    {
        $languages = $this->languageHandler->loadAll();

        $returnArray = array();
        foreach ($languages as $language) {
            $returnArray[] = $this->buildDomainObject($language);
        }

        return $returnArray;
    }
6050
public function callMiddleware($id, $owner)
    {
        if ($owner->freezed) {
            return $owner;
        }

        $class = get_class($owner);
        foreach ($owner->middleware as $definition) {
            $middleware = make($definition);
            if (!$middleware instanceof MiddlewareContract) {
                throw new InvalidConfigException(sprintf("'%s' is not a valid middleware", get_class($middleware)));
            }

            $result = $middleware->handle($owner);
            if ($result === false) {
                break;
            } elseif ($result instanceof $class) {
                $owner = $result;
            } elseif ($result !== null) {
                throw new InvalidValueException(sprintf(
                    'The return value of %s::handle() should be one of false, null and %s',
                    get_class($middleware), $class
                ));
            }
        }

        $this->bind($id, $owner, true);
        $owner->freeze();

        return $owner;
    }
415765
static public function getFirstLanguage($values)
    {
        $returnValue = array();

        if (count($values) > 0) {
            $previousLanguage = $values[0]['language'];
        
            foreach ($values as $value) {
                if ($value['language'] == $previousLanguage) {
                    $returnValue[] = $value['value'];
                } else {
                    break;
                }
            }
        }

        return (array) $returnValue;
    }
803972
public static function hydrateCollection(array $languages)
    {
        $hydrated = [];

        foreach ($languages as $language) {
            $hydrated[] = self::hydrate($language);
        }

        return $hydrated;
    }
1043955
public function getLanguagesWithMasterLanguagePromoted()
    {
        $languages = $this
            ->languageManager
            ->getLanguages()
            ->toArray();

        $masterLocale = $this
            ->masterLocale
            ->getIso();

        $index = array_search($masterLocale, $languages);

        if (false !== $index) {
            $mainLanguage = $languages[$index];
            unset($languages[$index]);
            array_unshift($languages, $mainLanguage);
        }

        return new ArrayCollection($languages);
    }
274486
public function makeTranslatable(Schema $property, $languages)
    {
        $property->setType('object');
        $property->setTranslatable(true);

        array_walk(
            $languages,
            function ($language) use ($property) {
                $schema = new Schema;
                $schema->setType('string');
                $schema->setTitle('Translated String');
                $schema->setDescription('String in ' . $language . ' locale.');
                $property->addProperty($language, $schema);
            }
        );
        $property->setRequired(['en']);
        return $property;
    }
542584
public function languages($config = array())
    {
          $config = new AnConfig($config);
          $path = ANPATH_SITE.DS.'language';
          $languages = preg_grep('/^([^.])/', scandir($path));
          $options = array();

          foreach($languages as $language){
              $manifest = json_decode(file_get_contents($path.DS.$language.DS.$language.'.json'));
              $options[] = array(
                'name' => $manifest->name,
                'value' => $language
              );
          }

          $config->options = $options;

          return $this->formfield_select($config);
    }
1028173
private function compareTranslations(array $default, array $languages)
    {
        // Return diff language by language
        foreach ($languages as $language) {
            $this->addOutput($language);
            $current = $this->getTranslations($this->basePath, $language);

            foreach ($default as $key => $values) {
                $valuesKeys = array_keys($values);

                foreach ($valuesKeys as $key2) {
                    if (in_array($key2, ['custom', 'attributes'], true)) {
                        continue;
                    }

                    if (!isset($current[$key][$key2])) {
                        $this->addOutput($language, "  * {$key} : {$key2} : not present");
                    } elseif ($current[$key][$key2] === $default[$key][$key2]) {
                        $this->addOutput($language, "  * {$key} : {$key2}");
                    }
                }
            }
        }
    }
405583
private function getMainLanguagesBySiteAccesses(array $siteAccesses)
    {
        $languages = array();

        foreach ($siteAccesses as $siteAccess) {
            $languageList = $this->configResolver->getParameter(
                'languages',
                '',
                $siteAccess !== 'default' ? $siteAccess : null
            );
            $mainLanguage = reset($languageList);

            if ($mainLanguage) {
                $languages[$mainLanguage] = $mainLanguage;
            }
        }

        return array_keys($languages);
    }
899089
private function loadLanguages(): iterable
    {
        if (method_exists($this->languageService, 'loadLanguageListByCode')) {
            return $this->languageService->loadLanguageListByCode($this->languageCodes);
        }

        // Deprecated: Remove when support for eZ kernel < 7.5 ends

        $languages = [];

        foreach ($this->languageCodes as $languageCode) {
            try {
                $language = $this->languageService->loadLanguage($languageCode);
            } catch (NotFoundException $e) {
                continue;
            }

            $languages[] = $language;
        }

        return $languages;
    }
497011
protected static function tagLanguage(array $values)
    {
        $lang   = null;
        $values = self::createLanguage($values, $lang);

        return $lang ? array_map(function($value) use ($lang) {
            return (object)['value' => $value, 'lang' => $lang];
        }, $values) : $values;
    }
616622
public function byLanguage($language = null)
    {
        if (!$language) {
            if (Yii::$app->id === 'app-backend') {
                $language = Yii::$app->wavecms->editedLanguage;
            } else {
                $language = Yii::$app->language;
            }
        }

        return $this->andWhere(['REGEXP', News::tableName() . '.languages', '(^|;)(' . $language . ')(;|$)']);
    }
191475
public function tocAction($owner, $ownerId)
    {
        /** @var BlockProviderInterface $provider */
        $provider = $this->get('opifer.content.block_provider_pool')->getProvider($owner);
        $object = $provider->getBlockOwner($ownerId);

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->setDraft(true)->setObject($object);
        $environment->setBlockMode('manage');

        $twigAnalyzer = $this->get('opifer.content.twig_analyzer');

        $parameters = [
            'environment' => $environment,
            'analyzer' => $twigAnalyzer,
            'object' => $environment->getObject(),
        ];

        return $this->render('OpiferContentBundle:Content:toc.html.twig', $parameters);
    }
8079
def _get_languages(cls) -> set:
        """"""
        if not cls._server_is_alive():
            cls._start_server_on_free_port()
        url = urllib.parse.urljoin(cls._url, 'Languages')
        languages = set()
        for e in cls._get_root(url, num_tries=1):
            languages.add(e.get('abbr'))
            languages.add(e.get('abbrWithVariant'))
        return languages