1 |
cb15593b
|
Cajova-Houba
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace Illuminate\Translation;
|
4 |
|
|
|
5 |
|
|
use Illuminate\Support\ServiceProvider;
|
6 |
|
|
|
7 |
|
|
class TranslationServiceProvider extends ServiceProvider
|
8 |
|
|
{
|
9 |
|
|
/**
|
10 |
|
|
* Indicates if loading of the provider is deferred.
|
11 |
|
|
*
|
12 |
|
|
* @var bool
|
13 |
|
|
*/
|
14 |
|
|
protected $defer = true;
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Register the service provider.
|
18 |
|
|
*
|
19 |
|
|
* @return void
|
20 |
|
|
*/
|
21 |
|
|
public function register()
|
22 |
|
|
{
|
23 |
|
|
$this->registerLoader();
|
24 |
|
|
|
25 |
|
|
$this->app->singleton('translator', function ($app) {
|
26 |
|
|
$loader = $app['translation.loader'];
|
27 |
|
|
|
28 |
|
|
// When registering the translator component, we'll need to set the default
|
29 |
|
|
// locale as well as the fallback locale. So, we'll grab the application
|
30 |
|
|
// configuration so we can easily get both of these values from there.
|
31 |
|
|
$locale = $app['config']['app.locale'];
|
32 |
|
|
|
33 |
|
|
$trans = new Translator($loader, $locale);
|
34 |
|
|
|
35 |
|
|
$trans->setFallback($app['config']['app.fallback_locale']);
|
36 |
|
|
|
37 |
|
|
return $trans;
|
38 |
|
|
});
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* Register the translation line loader.
|
43 |
|
|
*
|
44 |
|
|
* @return void
|
45 |
|
|
*/
|
46 |
|
|
protected function registerLoader()
|
47 |
|
|
{
|
48 |
|
|
$this->app->singleton('translation.loader', function ($app) {
|
49 |
|
|
return new FileLoader($app['files'], $app['path.lang']);
|
50 |
|
|
});
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Get the services provided by the provider.
|
55 |
|
|
*
|
56 |
|
|
* @return array
|
57 |
|
|
*/
|
58 |
|
|
public function provides()
|
59 |
|
|
{
|
60 |
|
|
return ['translator', 'translation.loader'];
|
61 |
|
|
}
|
62 |
|
|
}
|