Fetch I18n language line

@param string $key The string translated
@param string $path Optional path to your own language file
@return array|string
198530
protected function i18n($key = NULL, $path = NULL)
	{
		static $RECAPTCHA_LANG;

		if ( $RECAPTCHA_LANG ) {
			return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG;
		}

		if ( !isset($this->_recaptchaOptions['lang']) ) {
			$language = $this->clientLang();
		} else {
			$language = $this->_recaptchaOptions['lang'];
		}

		$RECAPTCHA_LANG = array(
			'instructions_visual' => 'Enter the words above:',
			'instructions_audio'  => 'Type what you hear:',
			'play_again'          => 'Play sound again',
			'cant_hear_this'      => 'Download sound as MP3',
			'visual_challenge'    => 'Get an image CAPTCHA',
			'audio_challenge'     => 'Get an audio CAPTCHA',
			'refresh_btn'         => 'Get another CAPTCHA',
			'help_btn'            => 'Help',
			'incorrect_try_again' => 'Incorrect, please try again.'
			);

	  	// default: path/to/vendor/lib/ReCaptcha/I18n/recaptcha.lang.[langcode].php
		$path = ( NULL === $path )
			? __DIR__ . DIRECTORY_SEPARATOR . 'I18n'
			: $path;

		$language_file = rtrim($path, '/') . DIRECTORY_SEPARATOR . 'recaptcha.lang.' . $language . '.php';

		if ( file_exists( $language_file  ) ) {

			include_once $language_file;
		}

		return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG;
	}
1067455
protected function findLanguageFiles($path)
    {
        // Loop through directories
        $dirIterator = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
        $recIterator = new \RecursiveIteratorIterator($dirIterator);

        // Fetch only php files - skip others
        $phpFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->phpRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $jsonFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->jsonRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $files = array_merge($phpFiles, $jsonFiles);

        // Sort array by filepath
        sort($files);

        // Remove full path from items
        array_walk($files, function (&$item) use ($path) {
            $item = str_replace($path, '', $item);
        });

        // Fetch non-vendor files from filtered php files
        $nonVendorFiles = array_filter($files, function ($file) {
            return strpos($file, $this->excludePath) === false && strpos($file, '.json') === false;
        });

        // Fetch vendor files from filtered php files
        $vendorFiles = array_filter(array_diff($files, $nonVendorFiles), function ($file) {
            return strpos($file, 'json') === false;
        });

        // Fetch .json files from filtered files
        $jsonFiles = array_filter($files, function ($file) {
            return strpos($file, '.json') !== false;
        });

        return [
            'lang'   => array_values($nonVendorFiles),
            'vendor' => array_values($vendorFiles),
            'json'   => array_values($jsonFiles),
        ];
    }
649480
protected function loadFormat($key)
    {
        if (isset($this->overwrites[$key])) {
            return $this->overwrites[$key];
        }

        foreach ($this->localeSequence() as $locale) {
            $path = "$locale.$key";
            if (isset($this->formats[$path])) {
                return $this->formats[$path];
            }
        }

        throw new KeyNotFoundException("Format for '$key' not found in formats.'");
    }
224907
public function loadTranslations($key, $pathToIniFile)
    {
        $path = $pathToIniFile;
        if(!is_file($path)) {
            throw new \InvalidArgumentException(sprintf("Translation file not found into path %s", $path));
        } else {
            $this->translations[$key] = parse_ini_file($path,true);
        }
    }
1234055
public function string($key, $language = '')
    {
        if (!$this->hasTranslations()) {
            return $this->container['lang'][$key];
        }

        if ($language == '') {
            $language = I18N::getCurrent();
        }

        if (array_key_exists('lang_' . $language, $this->container)) {
            return $this->container['lang_' . $language][$key];
        }

        return '';
    }
142366
public static function get($key, $params = array()) {
        if (static::$message === NULL) {
            static::setLanguage('en');
        }

        $rs = isset(static::$message[$key]) ? static::$message[$key] : $key;

        $names = array_keys($params);
        $names = array_map(array('\\PhalApi\\Translator', 'formatVar'), $names);

        return str_replace($names, array_values($params), $rs);
    }
937642
protected function lang($key)
    {
        if (count($this->language) < 1) {
            $this->setLanguage('en'); // set the default language
        }

        if (array_key_exists($key, $this->language)) {
            if ('smtp_connect_failed' == $key) {
                //Include a link to troubleshooting docs on SMTP connection failure
                //this is by far the biggest cause of support questions
                //but it's usually not PHPMailer's fault.
                return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
            }

            return $this->language[$key];
        }

        //Return the key as a fallback
        return $key;
    }
111314
public function getTranslationsFromFiles($domain, $path, array $directories = [])
    {
        if (!$directories) {
            $directories = [
                $path . 'Resources' . DIRECTORY_SEPARATOR . 'translations',
                $this->kernelRoot . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . $domain . DIRECTORY_SEPARATOR . 'translations',
            ];
        }

        $finder = new Finder();
        $translations = [];

        foreach ($directories as $directory) {
            if (is_dir($directory)) {
                $finder->files()
                    ->name($this->getFileNamePattern())
                    ->in($directory);

                foreach ($finder as $file) {
                    $translations = array_replace_recursive($this->getFileTranslationMessages($file, $domain), $translations);
                }
            }
        }

        return $translations;
    }
697356
public function getTranslation(
        string $language,
        string $key
    ) : Translation {
        $languages = $this
            ->repositoryCollection
            ->getTranslations(
                [],
                [$language],
                function (Translation $translation) use ($key) {
                    return $translation->getKey() === $key;
                }
            );

        $firstLanguage = reset($languages);

        return $firstLanguage;
    }
1103423
protected function getTranslationByLocaleKey($key)
    {
        foreach ($this->cachedTranslations() as $translation) {
            if ((int) $translation->getAttribute($this->getLocaleKey()) === (int) $key) {
                return $translation;
            }
        }

        return null;
    }
1108985
public function getLine($key, $replace = [], $locale = null, $fallback = true)
	{
		list($namespace, $group, $item) = $this->parseKey($key);

		// Here we will get the locale that should be used for the language line. If one
		// was not passed, we will use the default locales which was given to us when
		// the translator was instantiated. Then, we can load the lines and return.
		$locales = $fallback ? $this->localeArray($locale)
							 : [$locale ?: $this->locale];

		foreach ($locales as $locale) {
			if (! is_null($line = $this->read(
				$namespace, $group, $locale, $item, $replace
			))) {
				break;
			}
		}

		return isset($line) ? $line : null;
	}
1181816
public function getTranslationsForKey($key) {
		$this->getAllTranslationByLanguage();
		$translations = [];
		foreach ($this->messages as $language => $messages) {
			foreach ($messages as $messageKey => $message) {
				if($key == $messageKey) {
					$translations[$language] = $message;
				}
			}
		}
		return $translations;
	}
568181
public function get($key) 
    {
        return isset($this->langs[$key]) ? $this->langs[$key] : $key;
    }
565987
public function getIn($key, $path)
    {
        $target = $this->get($key);
        $path = (array) $path;

        if (!is_array($target)) {
            return false;
        }

        return \Owl\array_get_in($target, $path);
    }
1185469
public function retrieveAvailableLocales($path = '/../Resources/translations/')
    {
        $locales = array();
        $data = $this->configHandler->getParameter('locales');

        foreach ($data as $locale) {
            $locales[$locale] = $locale;
        }

        return $locales;
    }
161629
public function translate($key, $translation, $locale = null) {
        $locale = $this->locale($locale);

        return Lang::get($key, null, $locale);
    }
545707
private function translate($key, $translations)
    {
        if (!is_null($translations) && isset($translations[$key])) {
            return $translations[$key];
        }

        return $key;
    }