concrete/src/Localization/LocalizationEssentialServiceProvider.php
public function register()
    {
        if (!$this->app->bound(TranslatorAdapterFactoryInterface::class)) {
            $this->app->bind(TranslatorAdapterFactoryInterface::class, function ($app, $params) {
                $config = $app->make('config');
                $loaders = $config->get('i18n.adapters.zend.loaders', []);

                $loaderRepository = new TranslationLoaderRepository();
                foreach ($loaders as $key => $class) {
                    $loader = $app->build($class, [$app]);
                    $loaderRepository->registerTranslationLoader($key, $loader);
                }

                $serviceManager = new ServiceManager();
                $loaderPluginManager = new LoaderPluginManager(
                    $serviceManager,
                    [
                        'factories' => [
                            GettextLoader::class => function($creationContext, $resolvedName, $options) {
                                return $this->app->build(GettextLoader::class, ['webrootDirectory' => DIR_BASE]);
                            }
                        ],
                        'aliases' => [
                            'gettext' => GettextLoader::class,
                        ],
                    ]
                );
                $zendFactory = new ZendTranslatorAdapterFactory($loaderRepository, $loaderPluginManager);
                $plainFactory = new PlainTranslatorAdapterFactory();

                return new CoreTranslatorAdapterFactory($config, $plainFactory, $zendFactory);
            });
        }

        $this->app->singleton(Localization::class, function ($app) {
            $loc = new Localization();

            $translatorAdapterFactory = $app->make(TranslatorAdapterFactoryInterface::class);
            $repository = new TranslatorAdapterRepository($translatorAdapterFactory);
            $loc->setTranslatorAdapterRepository($repository);

            $loc->setActiveContext(Localization::CONTEXT_UI);

            return $loc;
        });
    }
public function register()
    {
        if (!$this->app->bound(TranslatorAdapterFactoryInterface::class)) {
            $this->app->bind(TranslatorAdapterFactoryInterface::class, function ($app, $params) {
                $config = $app->make('config');
                $loaders = $config->get('i18n.adapters.zend.loaders', []);

                $loaderRepository = new TranslationLoaderRepository();
                foreach ($loaders as $key => $class) {
                    $loader = $app->build($class, [$app]);
                    $loaderRepository->registerTranslationLoader($key, $loader);
                }

                $serviceManager = new ServiceManager();
                $loaderPluginManager = new LoaderPluginManager(
                    $serviceManager,
                    [
                        'factories' => [
                            GettextLoader::class => function($creationContext, $resolvedName, $options) {
                                return $this->app->build(GettextLoader::class, ['webrootDirectory' => DIR_BASE]);
                            }
                        ],
                        'aliases' => [
                            'gettext' => GettextLoader::class,
                        ],
                    ]
                );
                $zendFactory = new ZendTranslatorAdapterFactory($loaderRepository, $loaderPluginManager);
                $plainFactory = new PlainTranslatorAdapterFactory();

                return new CoreTranslatorAdapterFactory($config, $plainFactory, $zendFactory);
            });
        }

        $this->app->singleton(Localization::class, function ($app) {
            $loc = new Localization();

            $translatorAdapterFactory = $app->make(TranslatorAdapterFactoryInterface::class);
            $repository = new TranslatorAdapterRepository($translatorAdapterFactory);
            $loc->setTranslatorAdapterRepository($repository);

            $loc->setActiveContext(Localization::CONTEXT_UI);

            return $loc;
        });
    }
public function register ( ) { if ( ! $ this -> app -> bound ( TranslatorAdapterFactoryInterface :: class ) ) { $ this -> app -> bind ( TranslatorAdapterFactoryInterface :: class , function ( $ app , $ params ) { $ config = $ app -> make ( 'config' ) ; $ loaders = $ config -> get ( 'i18n.adapters.zend.loaders' , [ ] ) ; $ loaderRepository = new TranslationLoaderRepository ( ) ; foreach ( $ loaders as $ key => $ class ) { $ loader = $ app -> build ( $ class , [ $ app ] ) ; $ loaderRepository -> registerTranslationLoader ( $ key , $ loader ) ; } $ serviceManager = new ServiceManager ( ) ; $ loaderPluginManager = new LoaderPluginManager ( $ serviceManager , [ 'factories' => [ GettextLoader :: class => function ( $ creationContext , $ resolvedName , $ options ) { return $ this -> app -> build ( GettextLoader :: class , [ 'webrootDirectory' => DIR_BASE ] ) ; } ] , 'aliases' => [ 'gettext' => GettextLoader :: class , ] , ] ) ; $ zendFactory = new ZendTranslatorAdapterFactory ( $ loaderRepository , $ loaderPluginManager ) ; $ plainFactory = new PlainTranslatorAdapterFactory ( ) ; return new CoreTranslatorAdapterFactory ( $ config , $ plainFactory , $ zendFactory ) ; } ) ; } $ this -> app -> singleton ( Localization :: class , function ( $ app ) { $ loc = new Localization ( ) ; $ translatorAdapterFactory = $ app -> make ( TranslatorAdapterFactoryInterface :: class ) ; $ repository = new TranslatorAdapterRepository ( $ translatorAdapterFactory ) ; $ loc -> setTranslatorAdapterRepository ( $ repository ) ; $ loc -> setActiveContext ( Localization :: CONTEXT_UI ) ; return $ loc ; } ) ; }
Services that are essential for the loading of the localization
functionality.
Services that are essential for the loading of the localization functionality .