Skip to content

Commit

Permalink
Hooking into loading backend translations hook for each module
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Oct 16, 2017
1 parent 2951b67 commit 5a48554
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Modules/Core/Providers/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\EditorIsRendering;
use Modules\Core\Events\Handlers\RegisterCoreSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Foundation\Theme\ThemeManager;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
Expand Down Expand Up @@ -87,6 +88,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('core', RegisterCoreSidebar::class)
);
$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('core', array_dot(trans('core::core')));
$event->load('sidebar', array_dot(trans('core::sidebar')));
});
}

/**
Expand Down
5 changes: 5 additions & 0 deletions Modules/Dashboard/Providers/DashboardServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Dashboard\Entities\Widget;
Expand Down Expand Up @@ -44,6 +45,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('dashboard', RegisterDashboardSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('dashboard', array_dot(trans('dashboard::dashboard')));
});
}

public function boot(StylistThemeManager $theme)
Expand Down
6 changes: 6 additions & 0 deletions Modules/Media/Providers/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Media\Blade\MediaMultipleDirective;
Expand Down Expand Up @@ -66,6 +67,11 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('media', RegisterMediaSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('media', array_dot(trans('media::media')));
$event->load('folders', array_dot(trans('media::folders')));
});
}

public function boot(DispatcherContract $events)
Expand Down
6 changes: 6 additions & 0 deletions Modules/Menu/Providers/MenuServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Menu\Blade\MenuDirective;
Expand Down Expand Up @@ -47,6 +48,11 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('menu', RegisterMenuSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('menu', array_dot(trans('menu::menu')));
$event->load('menu-items', array_dot(trans('menu::menu-items')));
});
}

/**
Expand Down
5 changes: 5 additions & 0 deletions Modules/Setting/Providers/SettingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Setting\Blade\SettingDirective;
Expand Down Expand Up @@ -52,6 +53,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('setting', RegisterSettingSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('settings', array_dot(trans('setting::settings')));
});
}

public function boot()
Expand Down
5 changes: 5 additions & 0 deletions Modules/Tag/Providers/TagServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Tag\Blade\TagWidget;
Expand Down Expand Up @@ -41,6 +42,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('tag', RegisterTagSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('tags', array_dot(trans('tag::tags')));
});
}

public function boot()
Expand Down
5 changes: 5 additions & 0 deletions Modules/Translation/Providers/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\ServiceProvider;
use Modules\Core\Composers\CurrentUserViewComposer;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Translation\Console\BuildTranslationsCacheCommand;
Expand Down Expand Up @@ -45,6 +46,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('translation', RegisterTranslationSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('translations', array_dot(trans('translation::translations')));
});
}

public function boot()
Expand Down
5 changes: 5 additions & 0 deletions Modules/User/Providers/UserServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\User\Console\GrantModulePermissionsCommand;
Expand Down Expand Up @@ -68,6 +69,10 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('user', RegisterUserSidebar::class)
);
$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('users', array_dot(trans('user::users')));
$event->load('roles', array_dot(trans('user::roles')));
});
$this->commands([
GrantModulePermissionsCommand::class,
RemoveModulePermissionsCommand::class,
Expand Down
7 changes: 7 additions & 0 deletions Modules/Workshop/Providers/WorkshopServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Services\Composer;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
Expand Down Expand Up @@ -45,6 +46,12 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('workshop', RegisterWorkshopSidebar::class)
);

$this->app['events']->listen(LoadingBackendTranslations::class, function (LoadingBackendTranslations $event) {
$event->load('workshop', array_dot(trans('workshop::workshop')));
$event->load('modules', array_dot(trans('workshop::modules')));
$event->load('themes', array_dot(trans('workshop::themes')));
});
}

public function boot()
Expand Down

0 comments on commit 5a48554

Please sign in to comment.