public static function addResources(Application $app, $locale)
    {
        // Directories to look for translation file(s)
        $transDirs = array_unique(
            [
                $app['path_resolver']->resolve('%site%/app/translation/'),
                $app['path_resolver']->resolve("%site%/app/translation/{$locale}"),
                $app['path_resolver']->resolve("%bolt%/app/resources/translations/{$locale}"),
                $app['path_resolver']->resolve("%root%/app/resources/translations/{$locale}"), // Will be done better in v3.4
            ]
        );

        $needsSecondPass = true;

        $resources = [];

        foreach ($transDirs as $transDir) {
            if (!is_dir($transDir) || !is_readable($transDir)) {
                continue;
            }
            $iterator = new \DirectoryIterator($transDir);
            /** @var \SplFileInfo $fileInfo */
            foreach ($iterator as $fileInfo) {
                $ext = pathinfo($fileInfo, PATHINFO_EXTENSION);
                if (!$fileInfo->isFile() || !in_array($ext, ['yml', 'xlf'], true)) {
                    continue;
                }
                list($domain) = explode('.', $fileInfo->getFilename());
                $resources[] = [$ext, $fileInfo->getRealPath(), $locale, $domain];
                $needsSecondPass = false;
            }
        }

        if ($needsSecondPass && strlen($locale) === 5) {
            $resources = array_merge($resources, static::addResources($app, substr($locale, 0, 2)));
        }

        return $resources;
    }
public static function addResources(Application $app, $locale)
    {
        // Directories to look for translation file(s)
        $transDirs = array_unique(
            [
                $app['path_resolver']->resolve('%site%/app/translation/'),
                $app['path_resolver']->resolve("%site%/app/translation/{$locale}"),
                $app['path_resolver']->resolve("%bolt%/app/resources/translations/{$locale}"),
                $app['path_resolver']->resolve("%root%/app/resources/translations/{$locale}"), // Will be done better in v3.4
            ]
        );

        $needsSecondPass = true;

        $resources = [];

        foreach ($transDirs as $transDir) {
            if (!is_dir($transDir) || !is_readable($transDir)) {
                continue;
            }
            $iterator = new \DirectoryIterator($transDir);
            /** @var \SplFileInfo $fileInfo */
            foreach ($iterator as $fileInfo) {
                $ext = pathinfo($fileInfo, PATHINFO_EXTENSION);
                if (!$fileInfo->isFile() || !in_array($ext, ['yml', 'xlf'], true)) {
                    continue;
                }
                list($domain) = explode('.', $fileInfo->getFilename());
                $resources[] = [$ext, $fileInfo->getRealPath(), $locale, $domain];
                $needsSecondPass = false;
            }
        }

        if ($needsSecondPass && strlen($locale) === 5) {
            $resources = array_merge($resources, static::addResources($app, substr($locale, 0, 2)));
        }

        return $resources;
    }
public static function addResources ( Application $ app , $ locale ) { // Directories to look for translation file(s) $ transDirs = array_unique ( [ $ app [ 'path_resolver' ] -> resolve ( '%site%/app/translation/' ) , $ app [ 'path_resolver' ] -> resolve ( "%site%/app/translation/{$locale}" ) , $ app [ 'path_resolver' ] -> resolve ( "%bolt%/app/resources/translations/{$locale}" ) , $ app [ 'path_resolver' ] -> resolve ( "%root%/app/resources/translations/{$locale}" ) , // Will be done better in v3.4 ] ) ; $ needsSecondPass = true ; $ resources = [ ] ; foreach ( $ transDirs as $ transDir ) { if ( ! is_dir ( $ transDir ) || ! is_readable ( $ transDir ) ) { continue ; } $ iterator = new \ DirectoryIterator ( $ transDir ) ; /** @var \SplFileInfo $fileInfo */ foreach ( $ iterator as $ fileInfo ) { $ ext = pathinfo ( $ fileInfo , PATHINFO_EXTENSION ) ; if ( ! $ fileInfo -> isFile ( ) || ! in_array ( $ ext , [ 'yml' , 'xlf' ] , true ) ) { continue ; } list ( $ domain ) = explode ( '.' , $ fileInfo -> getFilename ( ) ) ; $ resources [ ] = [ $ ext , $ fileInfo -> getRealPath ( ) , $ locale , $ domain ] ; $ needsSecondPass = false ; } } if ( $ needsSecondPass && strlen ( $ locale ) === 5 ) { $ resources = array_merge ( $ resources , static :: addResources ( $ app , substr ( $ locale , 0 , 2 ) ) ) ; } return $ resources ; }
Adds all resources that belong to a locale.

@param Application $app
@param string      $locale

@return array
Adds all resources that belong to a locale .