app->singleton(LocaleInterface::class, fn () => $this->app->make(Locale::class)); // Replaces the default Laravel translator $this->app->alias(LocaleInterface::class, 'translator'); $this->app->alias(LocaleInterface::class, Translator::class); // Reuses the instance and keeps the user selected language across the application $this->app->singleton( IsoCodesFactory::class, fn (Container $container, array $params): IsoCodesFactory => new IsoCodesFactory( null, new IsoCodesTranslationDriver($params['locale'] ?? LocaleFacade::getLocale()) ) ); } /** * Get the services provided by the provider. * */ public function provides(): array { return [LocaleInterface::class, Translator::class, 'translator']; } }