Prints localized text
@param string $key The key (description) of the localized text
@param string $lang The output language. Default is default language.
@codeCoverageIgnore
772934
public function _e(string $key, ?string $lang = null): void
    {
        echo $this->__($key, $lang);
    }
132925
public function required($input, $key, $lang)
    {
        $lang = $this->custom('required', $lang);
        if (empty($input[$key])) {
            return str_replace(':field', $key, $lang);
        }
    }
448200
public function has($key, $locale = null) {
        $locale = $this->locale($locale);

        return Lang::has($key, $locale);
    }
1291094
public function translate(string $key, array $args = [], string $lang = '')
    {
        if (!\is_string($key)) {
            throw new \InvalidArgumentException('The translate key must be a string.');
        }

        $key = \trim($key, ' ' . $this->separator);
        if ($key === '') { // '0' is equals False
            throw new \InvalidArgumentException('Cannot translate the empty key');
        }

        [$lang, $key] = $this->parseKey($key, $lang);

        // translate form current language. if not found, translate form fallback language.
        if (($value = $this->findTranslationText($key)) === null) {
            $value = $this->transByFallbackLang($key);

            // no translate text
            if ((string)$value === '') {
                if (!empty($args['__default'])) {
                    return $args['__default'];
                }

                return \ucfirst(Str::toSnake(\str_replace(['-', '_'], ' ', $key), ' '));
            }
        }

        return $args ? sprintf($value, ...$args) : $value;
    }
264970
public function has(string $key, ?string $language = null): bool
	{
		[$file, $string] = $this->parseKey($key);

		if($string === null)
		{
			return false;
		}

		$strings = $this->getStrings($language ?? $this->language, $file);

		return Arr::has($strings, $string) && is_string(Arr::get($strings, $string));
	}
972276
public function offsetGet($key)
    {
        $langs = Languages::getInstance($this->getCategory());
        return (isset($langs[$this->code][$key])) ?
            $langs[$this->code][$key] :
            $langs[$langs->getDefault()][$key];
    }
1023735
public static function setLanguage($lang)
    {
        static::$_appLanguage = Yii::$app->language;

        Yii::$app->language = $lang;
    }
450003
protected function showHtmlAction($key, $table)
    {
        $html = $this->htmlCodeGenerator->generateHtml($key, $table);
        $this->view->assign('html', $html);
    }
978277
public static function lang($lang = null)
    {
        if ($lang)
        {
            self::$lang = strtolower(str_replace(self::$_langNormalizeSearch, self::$_langNormalizeReplace, $lang));
        }
        return self::$lang;
    }
513160
public function translate($key, $translation, $locale = null) {
        $this->translations[$this->locale($locale)][$key] = $translation;

        return $translation;
    }
1076345
public function setLanguageId($langid)
	{
		if ( $langid === $this->getLanguageId() ) { return; }

		$this->_values['langid'] = strtolower( (string) $langid );
		$this->setModified();
	}
511721
public function setValue($key, $value)
    {
        $this->langstrings[$key] = $value;
        $this->debug('SetValue ' . $key . ' => ' . $value);
    }
888660
public function translate(string $key, ?string $lang = null): ?string
    {
        try {
            // Validate key
            $key = strtolower($key);
            if (!preg_match('/^[a-z0-9\.\-\_]+$/', $key)) {
                throw new TranslatorException('Invalid translation key');
            }

            // Get current language
            $language = $this->_language($lang);
            $translation = $language->get($key);

            if ($translation) { // Translation found
                return $translation;
            }

            // Fallback
            try {
                $fallback = $this->_fallback();
            } catch (LanguageException $e) {
                throw new LanguageException('[Fallback] ' . $e->getMessage());
            }

            if ($fallback && $fallback->name() !== $language->name()) {
                $translation = $fallback->get($key);
                if ($translation) {
                    return $translation;
                }
            }
        } catch (TranslatorException $e) {
            trigger_error(sprintf('Translation error [%s]: %s', $key, $e->getMessage()), E_USER_WARNING);
        }

        return null;
    }
371545
public function translateArray($key, $index, $languages = null, $html_out = false)
    {
        if ($this->config->get('system.languages.translations', true)) {
            if ($this->enabled() && $key) {
                if (empty($languages)) {
                    if ($this->config->get('system.languages.translations_fallback', true)) {
                        $languages = $this->getFallbackLanguages();
                    } else {
                        $languages = (array)$this->getDefault();
                    }
                }
            } else {
                $languages = ['en'];
            }

            foreach ((array)$languages as $lang) {
                $translation_array = (array)Grav::instance()['languages']->get($lang . '.' . $key, null);
                if ($translation_array && array_key_exists($index, $translation_array)) {
                    return $translation_array[$index];
                }
            }
        }

        if ($html_out) {
            return '<span class="untranslated">' . $key . '[' . $index . ']</span>';
        }

        return $key . '[' . $index . ']';
    }
1162194
function addLanguage($languageKey, $content) {
        //If the langage exists and it's an array, add to it instead of replacing it.
        if (is_array($this->getLanguage($languageKey))) {
            $this->languages[$languageKey][] = $content[0];
            return;
        }
        $this->languages[$languageKey] = $content;
        return $this;
    }
670542
public function get($key, $alternative=null, $lang=null){

        if (!$lang) {
            $lang = $this->locale;
        }

        if (!$alternative){
            $alternative = $key;
        }

        return isset($this->_languages[$lang][$key]) ? $this->_languages[$lang][$key]:$alternative;
    }
630481
public String getLang(final Locale locale, final String key) {
        return langs.get(locale.toString()).getProperty(key);
    }