Returns language objects.

@param bool $active True/False according to the status of the language.
@param bool $asArray Return the languages as language object or as 'flat' array

@return Language|array

@deprecated since version 1.5.2
484956
public static function getLanguages($active = true, $asArray = false)
    {
        if ($active) {
            return self::find()->where(['status' => static::STATUS_ACTIVE])->asArray($asArray)->all();
        } else {
            return self::find()->asArray($asArray)->all();
        }
    }
1323869
public function files($active = true)
    {
        $query = $this->morphToMany(File::class, 'uploadable')
        ->with('translations')
        ->withPivot('weight')
        ->orderBy('weight', 'ASC')
        ->withTimestamps();

        if ($active) {
            $query->where('is_active', '=', 1);
        }

        return $query;
    }
238041
public function getExtension($asArray = false)
    {
        $asArray   = (bool) $asArray;
        $extension = (string) $this->_extension;
        if ($asArray) {
            $extension = explode(',', $extension);
        }

        return $extension;
    }
92157
public static function getLanguageNames($active = false)
    {
        $languageNames = [];
        foreach (self::getLanguages($active, true) as $language) {
            $languageNames[$language['language_id']] = $language['name'];
        }

        return $languageNames;
    }
827633
public function json($asArray = false)
    {
        $json = json_decode((string) $this->getBody(), $asArray);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new RuntimeException(sprintf("The response is not a valid json: %s", json_last_error_msg()));
        }

        return $json;
    }
875524
def active_language(self):
        
        # Current instance language (if user uses activate_language() method)
        if self._language is not None:
            return self._language

        # Current site language (translation.get_language())
        current = utils.get_language()
        if current in self.supported_languages:
            return current

        # Default language descriptor
        return self.default_language
1127353
public function languages($acceptLanguage = null)
    {
        if ($acceptLanguage === null) {
            $acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
        }

        if (!$acceptLanguage) {
            return [];
        }

        $languages = [];

        // Parse accept language string.
        foreach (explode(',', $acceptLanguage) as $piece) {
            $parts = explode(';', $piece);
            $language = strtolower($parts[0]);
            $priority = empty($parts[1]) ? 1. : floatval(str_replace('q=', '', $parts[1]));

            $languages[$language] = $priority;
        }

        // Sort languages by priority.
        arsort($languages);

        return array_keys($languages);
    }
1047560
public function getLanguages()
    {
        $url = $this->getGetLanguagesUrl();
        $response = $this->sendRequest(
            'GET',
            $url,
            [
                'version' => $this->serviceProtocolVersion
            ]
        );
        if ($response->getStatusCode() === 200) {
            $languages = $this->parseGetLanguagesResponse($response);
            return $languages;
        }
        return false;
    }
1356338
public function getAllEnabled()
    {
        $aEnabled = $this->oCi->config->item('languages_enabled');
        $aOut     = [];

        foreach ($aEnabled as $sCode) {
            $aOut[] = $this->getByCode($sCode);
        }

        return array_filter($aOut);
    }
725053
public function getActiveLocales()
	{
		$activeLocales = array();
		
		$locales = $this->getLocales();

		foreach ($locales as $id => $locale) {
			if ($locale->isActive()) {
				$activeLocales[$id] = $locale;
			}
		}

		return $activeLocales;
	}
1138439
public function fetch($asArray = false)
    {
        if ($asArray) {
            $r = $this->execute();

            if ($r && $this->_with) {
                $r = $this->relationsManager->earlyLoad($this->_model, $r, $this->_with, $asArray);
            }

            return $r;
        } else {
            $modelName = get_class($this->_model);
            $r = $this->execute();
            foreach ($r as $k => $v) {
                $r[$k] = new $modelName($v);
            }

            if ($r && $this->_with) {
                $r = $this->relationsManager->earlyLoad($this->_model, $r, $this->_with, $asArray);
            }

            if ($this->_multiple === false) {
                return isset($r[0]) ? $r[0] : null;
            } else {
                return $r;
            }
        }
    }
944337
public function getBrowserLanguages($accept_langs = [])
    {
        user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, no longer used', E_USER_DEPRECATED);

        if (empty($this->http_accept_language)) {
            if (empty($accept_langs) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                $accept_langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
            } else {
                return $accept_langs;
            }

            $langs = [];

            foreach (explode(',', $accept_langs) as $k => $pref) {
                // split $pref again by ';q='
                // and decorate the language entries by inverted position
                if (false !== ($i = strpos($pref, ';q='))) {
                    $langs[substr($pref, 0, $i)] = [(float)substr($pref, $i + 3), -$k];
                } else {
                    $langs[$pref] = [1, -$k];
                }
            }
            arsort($langs);

            // no need to undecorate, because we're only interested in the keys
            $this->http_accept_language = array_keys($langs);
        }
        return $this->http_accept_language;
    }
816518
protected function _cloneActiveContext($active_ctx) {
    $child = new stdClass();
    $child->{'@base'} = $active_ctx->{'@base'};
    $child->mappings = self::copy($active_ctx->mappings);
    $child->inverse = null;
    if(property_exists($active_ctx, '@language')) {
      $child->{'@language'} = $active_ctx->{'@language'};
    }
    if(property_exists($active_ctx, '@vocab')) {
      $child->{'@vocab'} = $active_ctx->{'@vocab'};
    }
    return $child;
  }
23882
public function asArray()
    {
        return [
            'id'        => $this->getId(),
            'className' => $this->getClassName(),
            'instance'  => $this->getInstance(),
            'arguments' => $this->getArguments(),
            'type'      => $this->getType(),
            'target'    => $this->getTarget(),
            'position'  => $this->getPosition(),
        ];
    }
8386
public function language(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateLanguage();
        $this->validateWeight();
        $this->validateBool('status');
        $this->validateBool('default');
        $this->validateNameLanguage();
        $this->validateNativeNameLanguage();
        $this->validateCodeLanguage();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
121270
public static function getAcceptLanguage(): array
    {
        if (!self::$language) {
            // get header from request
            self::$language = self::parseAcceptHeader(self::getHeader('Accept-Language'));
        }
        return self::$language;
    }
1084938
public function isActive($active = true)
    {
        if (! is_bool($active)) {
            $active = false;
        }
        $this->isActive = $active;

        return $this;
    }