|
2 | 2 |
|
3 | 3 | namespace JoeDixon\Translation; |
4 | 4 |
|
| 5 | +use Illuminate\Filesystem\Filesystem; |
5 | 6 | use Illuminate\Support\ServiceProvider; |
6 | 7 | use JoeDixon\Translation\Console\Commands\AddLanguageCommand; |
7 | 8 | use JoeDixon\Translation\Console\Commands\AddTranslationKeyCommand; |
8 | 9 | use JoeDixon\Translation\Console\Commands\ListLanguagesCommand; |
9 | 10 | use JoeDixon\Translation\Console\Commands\ListMissingTranslationKeys; |
10 | 11 | use JoeDixon\Translation\Console\Commands\SynchroniseMissingTranslationKeys; |
11 | 12 | use JoeDixon\Translation\Console\Commands\SynchroniseTranslationsCommand; |
| 13 | +use JoeDixon\Translation\Drivers\Translation; |
12 | 14 |
|
13 | 15 | class TranslationServiceProvider extends ServiceProvider |
14 | 16 | { |
@@ -44,6 +46,8 @@ public function register() |
44 | 46 | $this->mergeConfiguration(); |
45 | 47 |
|
46 | 48 | $this->registerCommands(); |
| 49 | + |
| 50 | + $this->registerContainerBindings(); |
47 | 51 | } |
48 | 52 |
|
49 | 53 | /** |
@@ -156,4 +160,22 @@ private function registerHelpers() |
156 | 160 | { |
157 | 161 | require __DIR__.'/../resources/helpers.php'; |
158 | 162 | } |
| 163 | + |
| 164 | + /** |
| 165 | + * Register package bindings in the container. |
| 166 | + * |
| 167 | + * @return void |
| 168 | + */ |
| 169 | + private function registerContainerBindings() |
| 170 | + { |
| 171 | + $this->app->singleton(Scanner::class, function () { |
| 172 | + $config = $this->app['config']['translation']; |
| 173 | + |
| 174 | + return new Scanner(new Filesystem, $config['scan_paths'], $config['translation_methods']); |
| 175 | + }); |
| 176 | + |
| 177 | + $this->app->singleton(Translation::class, function ($app) { |
| 178 | + return (new TranslationManager($app, $app['config']['translation'], $app->make(Scanner::class)))->resolve(); |
| 179 | + }); |
| 180 | + } |
159 | 181 | } |
0 commit comments