Modifying the state of language.

@return array
771515
public function run()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;

        $language = Language::findOne(Yii::$app->request->post('language_id', ''));
        if ($language !== null) {
            $language->status = Yii::$app->request->post('status', Language::STATUS_BETA);
            if ($language->validate()) {
                $language->save();
            }
        }

        return $language->getErrors();
    }
29423
public function translate()
	{
		$arguments = func_get_args();

		// Default translation parameters.
		$translate = array(
			'context' => $this->context(),
			'lang' => $this->lang(),
			'parameters' => $this->parameters(),
			'string' => $this->string(),
		);

		// Populate `$translate` variable with function arguments and/or model state.
		foreach ($this->_translate as $i => $element)
		{
			$this->_setup_element($translate, $element, $i, $arguments);
		}
		// Now that the basic data have been set, parameters that need to have context values.
		foreach ($this->_context_params as $parameter)
		{
			$translate['parameters'][$parameter] = $translate[self::CONTEXT];
		}

		// Translate using the populated data.
		return $this->i18n()
			->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']);
	}
1288175
public function languages()
    {
        $languages = array_map(function ($directory) {
            return basename($directory);
        }, $this->disk->directories($this->path));

        $languages = array_filter($languages, function ($directory) {
            return $directory != 'vendor' && $directory != 'json';
        });

        sort($languages);

        return Arr::except($languages, ['vendor', 'json']);
    }
556648
private function getMatchesFromAcceptedLanguages()
    {
        $matches = [];

        $acceptLanguages = $this->request->header('Accept-Language');

        if ( ! empty($acceptLanguages)) {
            $acceptLanguages = explode(',', $acceptLanguages);

            $genericMatches = $this->retrieveGenericMatches($acceptLanguages, $matches);

            $matches = array_merge($genericMatches, $matches);
            arsort($matches, SORT_NUMERIC);
        }

        return $matches;
    }
823347
protected function resolveLanguages()
    {
        if (!$this->get('accept_language')) {
            return [];
        }

        $codes = $this->extractHeaders();

        $languages = array();
        foreach ($codes as $lang) {
            if (strpos($lang, '-') !== false) {
                $codes = explode('-', $lang);
                $lang = strtolower($codes[0]);
            }

            if (in_array($lang, $languages)) {
                continue;
            }

            $languages[] = $lang;
        }

        return $languages;
    }
995708
public function getFallbackLanguages()
    {
        if (empty($this->fallback_languages)) {
            if ($this->enabled()) {
                $fallback_languages = $this->languages;

                if ($this->active) {
                    $active_extension = $this->active;
                    $key = \array_search($active_extension, $fallback_languages, true);
                    unset($fallback_languages[$key]);
                    array_unshift($fallback_languages, $active_extension);
                }
                $this->fallback_languages = $fallback_languages;
            }
            // always add english in case a translation doesn't exist
            $this->fallback_languages[] = 'en';
        }

        return $this->fallback_languages;
    }
37259
public function getIntegrationLanguage() {
        // Get and format the user language
        $userLanguage = $this->localeResolver->getLocale();
        $userLanguage = strtoupper(str_replace('_', '-', $userLanguage));

        // Get and format the supported languages
        $supportedLanguages = [];
        foreach (self::getSupportedLanguages() as $arr) {
            $supportedLanguages[] = $arr['value'];
        }

        // Get the fallback language
        $fallbackLanguage = $this->getValue(
            self::KEY_FALLBACK_LANGUAGE,
            $this->storeManager->getStore()
        );

        // Compare user language with supported
        if (in_array($userLanguage, $supportedLanguages)) {
            return $userLanguage;
        }
        else {
            return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN';
        }
    }
1317470
protected function buildAlternateTranslations()
    {
        $translations = [];

        $context  = $this->contextObject();
        $origLang = $this->currentLanguage();

        $this->translator()->isIteratingLocales = true;
        foreach ($this->locales() as $langCode => $localeStruct) {
            if ($langCode === $origLang) {
                continue;
            }

            $this->translator()->setLocale($langCode);

            $translations[$langCode] = $this->formatAlternateTranslation($context, $localeStruct);
        }

        $this->translator()->setLocale($origLang);
        unset($this->translator()->isIteratingLocales);

        return $translations;
    }
789799
public static function getRules()
    {
        $rules = static::rules();

        if (RevyAdmin::isTranslationMode()) {
            $object = new static();

            foreach ($rules as $field => $rule) {
                if ($object->isTranslatableField($field)) {
                    unset($rules[$field]);
                    foreach (Language::getLocales() as $locale) {
                        $rules[RevyAdmin::getTranslationFieldName($field, $locale)] = $rule;
                    }
                }
            }
        }
      
        return $rules;
    }
57266
public function appendLanguageKeys()
    {
        $attributes = $this->getAttributes();
        foreach($attributes as $attrKey => $attr){
            if(isset($this->translatableColumns[$attrKey])) {
                if(is_array($attr)) {
                    continue;
                }
                if($attr == null || $attr == "" || $attr == '[]') {
                    $attr = new \stdClass();
                }else{
                    if(!is_object($attr)) {
                        $attr = json_decode($attr);
                    }
                }
                foreach(Language::all() as $language){
                    $langSlug = $language->slug;

                    if (!isset($attr->$langSlug)) {
                        if($this->translatableColumns[$attrKey] == "string") {
                            $attr->$langSlug = "";
                        }else{
                            $attr->$langSlug = [];
                        }
                    }
                }
                $this->$attrKey = $attr;
            }
        }
        return $this;
    }
978887
public function encodings()
    {
        $encodings = [];
        $added = [];

        foreach ($this->candidates as $candidate) {
            foreach ($candidate->encodings() as $encoding) {
                if (isset($added[$encoding])) {
                    continue;
                }
                $encodings[] = $encoding;
                $added[$encoding] = true;
            }
        }

        return $encodings;
    }
805645
public function inputSuffix()
    {
        if ($this->inputSuffix instanceof Translation) {
            if (isset($this->inputSuffix->isRendered) && $this->inputSuffix->isRendered === false) {
                $this->inputSuffix = $this->renderTranslatableTemplate($this->inputSuffix);
            }

            if ($this->lang()) {
                return $this->inputSuffix[$this->lang()];
            }
        }

        return $this->inputSuffix;
    }
121270
public static function getAcceptLanguage(): array
    {
        if (!self::$language) {
            // get header from request
            self::$language = self::parseAcceptHeader(self::getHeader('Accept-Language'));
        }
        return self::$language;
    }
1026689
public function getLanguages()
    {
        if (!is_array($this->languages)) {
            LanguageDetector::detect($this, $this->getAcceptLanguage());
        }

        return $this->languages;
    }
367217
public function getLanguages()
    {
        // Cache by locale
        $locale = i18n::get_locale();
        if (!empty(static::$cache_languages[$locale])) {
            return static::$cache_languages[$locale];
        }

        // Localise all languages
        $languages = $this->config()->get('languages');
        $localised = [];
        foreach ($languages as $code => $default) {
            $localised[$code] = $this->languageName($code);
        }

        // Save cache
        static::$cache_languages[$locale] = $localised;
        return $localised;
    }
140908
protected function getContentLanguageCodes()
    {
        return array_map(
            function($language) {
                return $language->languageCode;
            },
            array_filter(
                $this->repository->getContentLanguageService()->loadLanguages(),
                function ($language) {
                    return $language->enabled;
                }
            )
        );
    }
277120
function languages()
    {
        // trust configuration
        $configured = $this->rc->config->get('spellcheck_languages');
        if (!empty($configured) && is_array($configured) && !$configured[0]) {
            return $configured;
        }
        else if (!empty($configured)) {
            $langs = (array)$configured;
        }
        else if ($this->backend) {
            $langs = $this->backend->languages();
        }

        // load index
        @include(RCUBE_LOCALIZATION_DIR . 'index.inc');

        // add correct labels
        $languages = array();
        foreach ($langs as $lang) {
            $langc = strtolower(substr($lang, 0, 2));
            $alias = $rcube_language_aliases[$langc];
            if (!$alias) {
                $alias = $langc.'_'.strtoupper($langc);
            }
            if ($rcube_languages[$lang]) {
                $languages[$lang] = $rcube_languages[$lang];
            }
            else if ($rcube_languages[$alias]) {
                $languages[$lang] = $rcube_languages[$alias];
            }
            else {
                $languages[$lang] = ucfirst($lang);
            }
        }

        // remove possible duplicates (#1489395)
        $languages = array_unique($languages);

        asort($languages);

        return $languages;
    }