|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Pterodactyl - Panel |
|
4
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>. |
|
5
|
|
|
* |
|
6
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
8
|
|
|
* in the Software without restriction, including without limitation the rights |
|
9
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
11
|
|
|
* furnished to do so, subject to the following conditions: |
|
12
|
|
|
* |
|
13
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
14
|
|
|
* copies or substantial portions of the Software. |
|
15
|
|
|
* |
|
16
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
22
|
|
|
* SOFTWARE. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace Pterodactyl\Providers; |
|
26
|
|
|
|
|
27
|
|
|
use Pterodactyl\Extensions\PhraseAppTranslator; |
|
28
|
|
|
use Illuminate\Translation\TranslationServiceProvider; |
|
29
|
|
|
use Illuminate\Translation\Translator as IlluminateTranslator; |
|
30
|
|
|
|
|
31
|
|
|
class PhraseAppTranslationProvider extends TranslationServiceProvider { |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Register the service provider. |
|
35
|
|
|
* |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
public function register() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->registerLoader(); |
|
41
|
|
|
|
|
42
|
|
|
$this->app->singleton('translator', function ($app) { |
|
43
|
|
|
$loader = $app['translation.loader']; |
|
44
|
|
|
|
|
45
|
|
|
// When registering the translator component, we'll need to set the default |
|
46
|
|
|
// locale as well as the fallback locale. So, we'll grab the application |
|
47
|
|
|
// configuration so we can easily get both of these values from there. |
|
48
|
|
|
$locale = $app['config']['app.locale']; |
|
49
|
|
|
|
|
50
|
|
|
if ($app['config']['app.phrase_in_context']) { |
|
51
|
|
|
$trans = new PhraseAppTranslator($loader, $locale); |
|
52
|
|
|
} else { |
|
53
|
|
|
$trans = new IlluminateTranslator($loader, $locale); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$trans->setFallback($app['config']['app.fallback_locale']); |
|
57
|
|
|
|
|
58
|
|
|
return $trans; |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|