Get found translation lines found per file.

e.g. ['users.blade.php' => ['users.name'], 'users/index.blade.php' => ['users.phone', 'users.city']]

@return array
508532
public function getAllViewFilesWithTranslations()
    {
        /*
         * This pattern is derived from Barryvdh\TranslationManager by Barry vd. Heuvel <barryvdh@gmail.com>
         *
         * https://github.com/barryvdh/laravel-translation-manager/blob/master/src/Manager.php
         */
        $functions = ['__', 'trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice'];

        $pattern =
            // See https://regex101.com/r/jS5fX0/4
            '[^\w]'. // Must not start with any alphanum or _
            '(?<!->)'. // Must not start with ->
            '('.implode('|', $functions).')'.// Must start with one of the functions
            "\(".// Match opening parentheses
            "[\'\"]".// Match " or '
            '('.// Start a new group to match:
            '[a-zA-Z0-9_-]+'.// Must start with group
            "([.][^\1)$]+)+".// Be followed by one or more items/keys
            ')'.// Close group
            "[\'\"]".// Closing quote
            "[\),]"  // Close parentheses or new parameter
        ;

        $allMatches = [];

        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($this->disk->allFiles($this->syncPaths) as $file) {
            if (preg_match_all("/$pattern/siU", $file->getContents(), $matches)) {
                $allMatches[$file->getRelativePathname()] = $matches[2];
            }
        }

        return $allMatches;
    }
974993
public function getAcceptLanguages(): array
    {
        $ls = [];

        if ($value = $this->getLine('Accept-Language')) {
            if (\strpos($value, ';')) {
                [$value,] = \explode(';', $value, 2);
            }

            $value = \str_replace(' ', '', $value);
            $ls    = \explode(',', $value);
        }

        return $ls;
    }
1100091
public function getSupportedLanguages($full_names = false)
    {
        // return array
        $back = [];

        // we walk the lang root
        $dir = dir(self::LANG_ROOT);

        // foreach entry
        while (false !== ($entry = $dir->read())) {
            $full_path = self::LANG_ROOT . $entry;

            // Skip all dirs
            if (is_dir($full_path)) {
                continue;
            }

            // we only want lang.php files
            if (!preg_match('/^([^.]+)\.php$/', $entry, $matches)) {
                continue;
            }

            // Raw lang name is here
            $langname = $matches[1];

            // We want the fullname too?
            if ($full_names === true) {
                if (false !== ($fullname = $this->getLanguageFullname($langname))) {
                    $back[$langname] = $fullname; // we go associative
                }
            }
            else {
                // just store raw langname
                $back[] = $langname;
            }
        }

        $dir->close();

        return $back;
    }
462809
protected function getTargetRow(): array
    {
        $row = $this->dictionary->getRow($this->targetId);
        if (!$row) {
            throw new TranslationNotFoundException($this->getKey(), $this->dictionary);
        }

        return $row;
    }
419881
static function fetchList( $localeList = array() )
    {
        $ini = eZINI::instance();

        $dir = $ini->variable( 'RegionalSettings', 'TranslationRepository' );

        $fileInfoList = array();
        $translationList = array();
        $locale = '';

        if ( count( $localeList ) == 0 )
        {
            $localeList = eZDir::findSubdirs( $dir );
        }

        foreach( $localeList as $locale )
        {
            if ( $locale != 'untranslated' )
            {
                $translationFiles = eZDir::findSubitems( $dir . '/' . $locale, 'f' );

                foreach( $translationFiles as $translationFile )
                {
                    if ( eZFile::suffix( $translationFile ) == 'ts' )
                    {
                        $translationList[] = new eZTSTranslator( $locale,  $translationFile );
                    }
                }
            }
        }

        return $translationList;
    }
769335
protected static function get_target_locales()
    {
        // if locales are explicitly set, use these
        if (is_array(self::config()->locales)) {
            return (array)self::config()->locales;
            // otherwise check the allowed locales. If these have been set, use these
        } else if (is_array(Translatable::get_allowed_locales())) {
            return (array)Translatable::get_allowed_locales();
        }

        // last resort is to take the existing content languages
        return array_keys(Translatable::get_existing_content_languages());
    }
656813
private function contentMessages()
    {
        $savedTranslations = $this->readSavedTranslations();
        // An exception occurred when reading the file
        if ($savedTranslations === null) {
            return '';
        }

        $this->gatherTranslatableStrings();

        // Find already translated strings
        $newTranslations = [];
        foreach (array_keys($this->translatables) as $key) {
            $newTranslations[$key] = isset($savedTranslations[$key]) ? $savedTranslations[$key] : '';
        }
        ksort($newTranslations);

        try {
            return $this->buildNewContent($newTranslations, $savedTranslations);
        } catch (InvalidResourceException $e) {
            // last resort fallback, edit the file
            return file_get_contents($this->absPath);
        }
    }
224653
public function getAllTranslations()
    {
        $this->loadTranslations($this->currentLanguage);

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

        return $this->translations[$this->currentLanguage];
    }
1278555
public function translations()
    {
        $model = '\\'.get_class($this);

        if (isset($this->translatable))
        {
            return $model::where('translation_of', $this->id)->get();
        }

        return collect();
    }
955451
public function collectFromFiles()
    {
        $translationKeys = [];

        foreach ($this->getAllViewFilesWithTranslations() as $file => $matches) {
            foreach ($matches as $key) {
                try {
                    list($fileName, $keyName) = explode('.', $key, 2);
                } catch (\ErrorException $e) {
                    continue;
                }

                if (isset($translationKeys[$fileName]) && in_array($keyName, $translationKeys[$fileName])) {
                    continue;
                }

                $translationKeys[$fileName][] = $keyName;
            }
        }

        return $translationKeys;
    }
201344
public function getTranslatedLinkTargets()
    {
        $translatedLinkTargets = [];
        foreach ($this->linkTargets as $key => $value) {
            $translatedLinkTargets[$key] = $value;
        }

        return $translatedLinkTargets;
    }
1019070
public function getUseLines()
    {
        $lines = [];

        $lines = array_merge($lines, $this->getUseLinesSymfony2Part());

        $lines[] = 'use Doctrine\ORM\Mapping as ORM;';

        $useArrayCollection = false;

        foreach ($this->getEntity()->getAttributes() as $attr) {
            if (null !== $attr->getForeign() && 'array' === $attr->getType()) {
                $useArrayCollection = true;
                break;
            }
        }

        if ($useArrayCollection) {
            $lines[] = 'use Doctrine\\Common\\Collections\\ArrayCollection;';
        }


        $lines = array_merge($lines, $this->getUseLinesUserAdditionsPart());

        return $lines;
    }
41892
public function getTranslatedFields(): array
    {
        return Hash::apply($this->config('fields'), '{*}[searchable=true]', function ($array) {
            $formatted = [];
            foreach ($array as $data) {
                $formatted[$data['name']] = $data['translation'];
            }

            return Hash::sort($formatted, '{s}', 'asc');
        });
    }
332591
public static function getAvailableLanguages(){
        $languages = array();
        foreach(common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension){
           $localesDir = $extension->getDir() . 'locales/';
           foreach(glob($localesDir . '*') as  $file){
                if(is_dir($file) && file_exists($file . '/messages.po')){
                    $lang = basename($file);
                    if(!in_array($lang, $languages)){
                        $languages[] = $lang;
                    }
                }
           }
        } 
        return $languages;
    }
776676
public function allTranslations()
    {
        $model = '\\'.get_class($this);

        // the translations
        $translations = $this->translations();

        $all_translations = new Collection();
        // the original
        if ($this->translation_of) {
            $original = $model::find($this->translation_of);
            $all_translations = $all_translations->push($original);

            // get all translations from the original
            $translationsOfOriginal = $model::where('translation_of', $original->id)->get();
            foreach($translationsOfOriginal as $translation) {
                $all_translations->push($translation);
            }
        } else {
            // prepend the translation to be first in the list of translations
            $all_translations = $translations->prepend($this);
        }

        return $all_translations;
    }
1083045
protected function getLocaleChoices()
    {
        $localeChoices = [];

        if (!$this->request) {
            return [];
        }

        if (!$this->getRequest()->get('locale')) {
            $locale = $this->getRequest()->getLocale();
        } else {
            $locale = $this->getRequest()->get('locale');
        }

        if (is_array($locale) && array_key_exists('value', $locale)) {
            $locale = $locale['value'];
        }

        $localeList = Intl::getLocaleBundle()->getLocaleNames(substr($locale, 0, 2));

        foreach ($this->languages as $language) {
            $localeChoices[$localeList[$language['locale']]] = $language['locale'];
        }

        return $localeChoices;
    }
1018340
public function availableLocales()
    {
        if ($this->config->has('translator.locales')) {
            return $this->config->get('translator.locales');
        }

        if ($this->config->get('translator.source') !== 'files') {
            if ($this->tableExists()) {
                $locales = $this->model->distinct()->get()->pluck('locale')->toArray();
                $this->config->set('translator.locales', $locales);
                return $locales;
            }
        }

        return $this->defaultAvailableLocales;
    }