Skip to content

Commit

Permalink
Locale: Don't resolve manager just to configure it
Browse files Browse the repository at this point in the history
Refs #1578.
  • Loading branch information
franzliedke authored and wzdiyb committed Feb 16, 2020
1 parent 05d7dd8 commit bf0285f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Locale/LocaleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ class LocaleServiceProvider extends AbstractServiceProvider
*/
public function boot(Dispatcher $events)
{
$locales = $this->app->make('flarum.locales');

$locales->addLocale($this->getDefaultLocale(), 'Default');

$events->dispatch(new ConfigureLocales($locales));

$events->listen(ClearingCache::class, function () use ($locales) {
$locales->clearCache();
$events->listen(ClearingCache::class, function () {
$this->app->make('flarum.locales')->clearCache();
});
}

Expand All @@ -43,10 +37,16 @@ public function boot(Dispatcher $events)
public function register()
{
$this->app->singleton(LocaleManager::class, function () {
return new LocaleManager(
$locales = new LocaleManager(
$this->app->make('translator'),
$this->getCacheDir()
);

$locales->addLocale($this->getDefaultLocale(), 'Default');

event(new ConfigureLocales($locales));

return $locales;
});

$this->app->alias(LocaleManager::class, 'flarum.locales');
Expand Down

0 comments on commit bf0285f

Please sign in to comment.