gets translations from files

@return array
324641
public function translationsFromFiles($locale)
    {
        $grouped = [];
        foreach ($this->hints as $name => $hint) {
            $languageDirectory = $hint . DIRECTORY_SEPARATOR . $locale;
            if (!is_dir($languageDirectory)) {
                continue;
            }
            $files = $this->filesystem->allFiles($languageDirectory);
            foreach ($files as $filename) {
                $file         = str_replace('.' . $filename->getExtension(), '', $filename->getFilename());
                $translations = array_dot(require $filename->getRealPath());
                foreach ($translations as $key => $translation) {
                    $grouped[$name] [$file . '.' . $key] = $translation;
                }
            }
        }
        return $grouped;
    }
995759
public function filters()
    {
        $filters = $this->files();

        if ($only = config('administrator.translations.filters.only', [])) {
            $filters = $filters->intersect($only);
        }

        if ($except = config('administrator.translations.filters.except', [])) {
            $filters = $filters->diff($except);
        }

        return $filters;
    }
927367
public static function getAllPlugins()
    {
        static $pluginsWithTranslations;

        if (!empty($pluginsWithTranslations)) {
            return $pluginsWithTranslations;
        }

        $pluginsWithTranslations = array();
        foreach (Manager::getPluginsDirectories() as $pluginsDir) {
            $pluginsWithTranslations = array_merge($pluginsWithTranslations, glob(sprintf('%s*/lang/en.json', $pluginsDir)));
        }
        $pluginsWithTranslations = array_map(function ($elem) {
            $replace = Manager::getPluginsDirectories();
            $replace[] = '/lang/en.json';
            return str_replace($replace, '', $elem);
        }, $pluginsWithTranslations);

        return $pluginsWithTranslations;
    }
1028949
private function getFileResources()
    {
        $paths = array();

        foreach ($this->directories as $directory) {
            foreach ($directory as $file) {
                $relative = $this->getRelativeName($file, $directory);

                if (!isset($paths[$relative])) {
                    $paths[$relative] = $file;
                }
            }
        }

        return array_values($paths);
    }
246449
private function getI18nStats()
	{
		$selected_instance   = $this->filter_post->getString( 'instance' );
		$selected_raw_locale = $this->filter_post->getString( 'locale' );

		list( $file_type, $language_code, $country_code_and_extension ) = explode( '_', $selected_raw_locale );
		$this->assign( 'language', $language_code );
		$locale = $language_code . '_' . $country_code_and_extension[0] . $country_code_and_extension[1];

		$literals = $this->getLiterals( $selected_instance );
		$this->assign( 'literals', $literals );

		try
		{
			\Sifo\I18N::setDomain( $file_type, $locale, $selected_instance );
			$translations_i18 = \Sifo\I18N::$translations;

			$missing_messages  = array_diff_key( $literals, $translations_i18[$file_type . '_' . $locale] );
			$leftover_messages = array_diff_key( $translations_i18[$file_type . '_' . $locale], $literals );

			$this->assign( 'selected_instance', $selected_instance );
			$this->assign( 'missing_messages', $missing_messages );
			$this->assign( 'leftover_messages', $leftover_messages );
			$this->assign( 'selected_locale', $selected_raw_locale );
			$this->assign( 'selected_charset', $this->filter_post->getString( 'charset' ) );
		}
		catch ( \Sifo\Exception_500 $exception )
		{
			$this->assign( 'error', $exception->getMessage() );
		}
	}
409231
public function getFiles() : array
    {
        Filesystem::checkExists($this->path);
        Filesystem::checkReadable($this->path);
        $contents = [];

        $files = scandir($this->path);
        foreach ($files as $file) {
            if($file != '.' && $file != '..') {
                $contents[] = Filesystem::get("$this->path/$file");
            }
        }
        return $contents;
    }
1320296
public function getMessages(): array
    {
        $errors = $this->getErrors();

        $keys = array_keys($errors);

        return array_reduce($keys, function ($messages, $key) use ($errors) {

            $translated = $this->translator->getMessages($key, $errors[$key]);

            return array_merge($messages, $translated);

        }, []);
    }
1154243
public function readTranslation($module) {
		
		// get the right translation folder
		$file = APPLICATION_PATH . (is_a($module,'Pair\Module') ? '/modules/' . $module->name : '') . '/translations/' . $this->getRepresentation() . '.ini';
		
		// checks that folder exists
		if (file_exists($file)) {
			
			// scans file and gets translation strings
			$strings = parse_ini_file($file);
			return (is_array($strings) ? $strings : array());
			
		} else {
			
			return array();
			
		}
		
	}
197690
public function getTranslator()
    {
        if (!$this->_translator) {

			$this->_translator = new \Zend_Translate(   
				'gettext', 
				CMSROOT . 'lang',  
				$this->_locale,  
				array('scan'=>\Zend_Translate::LOCALE_FILENAME)
			); 

        }
        return $this->_translator;
    }
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;
    }
771537
protected function getMessages()
    {
        $messages = [];
        $path     = $this->sourcePath;

        if ( ! $this->file->exists($path)) {
            throw new \Exception("${path} doesn't exists!");
        }

        foreach ($this->file->allFiles($path) as $file) {
            $pathName = $file->getRelativePathName();

            if ($this->file->extension($pathName) !== 'php') {
                continue;
            }

            if ($this->isMessagesExcluded($pathName)) {
                continue;
            }

            $key = substr($pathName, 0, -4);
            $key = str_replace('\\', '.', $key);
            $key = str_replace('/', '.', $key);

            $messages[$key] = include $path . DIRECTORY_SEPARATOR . $pathName;
        }

        foreach ($this->file->allFiles(resource_path('lang')) as $file) {
            $pathName = $file->getRelativePathName();

            if ($this->file->extension($pathName) !== 'json') {
                continue;
            }
            $key                     = substr($pathName, 0, -4);
            $key                     = str_replace('\\', '.', $key);
            $key                     = str_replace('/', '.', $key);
            $messages[$key . 'json'] = json_decode(file_get_contents($file->getRealPath()));
        }

        return $messages;
    }
404531
protected function translations()
    {
        $translations = collect($this->getFiles(resource_path('lang/')))->flatMap(function ($file) {
            return [
                ($translation = $file->getBasename('.php')) => trans($translation),
            ];
        });

        return $translations->merge($this->packageTranslations());
    }
224653
public function getAllTranslations()
    {
        $this->loadTranslations($this->currentLanguage);

        if (!isset($this->translations[$this->currentLanguage])) {
            return array();
        }

        return $this->translations[$this->currentLanguage];
    }
996414
public function getSupportedLocales()
    {
        $return = [];
        $process = new Process(['locale', '-a']);
        $process->run();
        $installedLocales = explode(PHP_EOL, trim($process->getOutput()));
        foreach ($this->supportedLocales as $supportedLocale) {
            if (in_array($supportedLocale, $installedLocales)
                || in_array($supportedLocale.'.utf8', $installedLocales)
            ) {
                $return[] = new Locale($supportedLocale);
            }
        }

        return $return;
    }
816419
public function readLanguagesFiles()
    {
        $translates = array();

        $options = $this->getServiceManager()->get('playgroundtranslate_module_options');
        $pathTranslate = $options->getLanguagePath();

        $dir = opendir(__DIR__.$pathTranslate);
        while ($file = readdir($dir)) {
            if ($file != '.' && $file != '..' && !is_dir(__DIR__.$pathTranslate.$file)) {
                $translates[basename(__DIR__.$pathTranslate.$file, '.php')] = @include __DIR__.$pathTranslate.$file;
            }
        }

        return $translates;
    }
61372
protected function getLocalCatalogs()
    {
        $result = array();

        $folders = array(
            $this->srcDir,
            dirname($this->srcDir) . '/app',
        );

        foreach($folders as $folder){
            $finder = new Finder();
            $finder->files()->in($folder)->name('/\w+\.\w+\.yml$/i');

            foreach($finder as $file){
                //$yml = $file->getRealpath();
                //$relativePath = $file->getRelativePath();
                $fileName = $file->getRelativePathname();

                if(preg_match("/translations\/(\w+)\.(\w+)\.yml/i", $fileName, $matches)){
                    $catalog = $matches[1];
                    $result[$catalog] = null;
                }
            }
        }

        return array_keys($result);
    }
538905
protected function getLanguagesInstall()
    {
        $languages = array();

        foreach ($this->language->getList() as $code => $language) {
            if ($code === 'en' || is_file($this->translation->getFile($code))) {
                $languages[$code] = $language;
            }
        }

        return $languages;
    }