1 | <?php |
||
14 | class PublishCommand extends AbstractCommand |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * The name and signature of the console command. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $signature = 'trans:publish |
||
27 | {locale : The language to publish the translations.} |
||
28 | {--force : Force to override the translations} |
||
29 | {--inline : Publish the inline translations} |
||
30 | {--json : Include json translations file}'; |
||
31 | |||
32 | /** |
||
33 | * The console command description. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $description = 'Publish the [locale] translations.'; |
||
38 | |||
39 | /** |
||
40 | * The TransPublisher instance. |
||
41 | * |
||
42 | * @var \Arcanedev\LaravelLang\Contracts\TransPublisher |
||
43 | */ |
||
44 | private $publisher; |
||
45 | |||
46 | /* ----------------------------------------------------------------- |
||
47 | | Constructor |
||
48 | | ----------------------------------------------------------------- |
||
49 | */ |
||
50 | |||
51 | /** |
||
52 | * Create a new console command instance. |
||
53 | * |
||
54 | * @param \Arcanedev\LaravelLang\Contracts\TransPublisher $publisher |
||
55 | */ |
||
56 | 48 | public function __construct(TransPublisher $publisher) |
|
63 | |||
64 | /* ----------------------------------------------------------------- |
||
65 | | Main Methods |
||
66 | | ----------------------------------------------------------------- |
||
67 | */ |
||
68 | |||
69 | /** |
||
70 | * Execute the console command. |
||
71 | */ |
||
72 | 36 | public function handle(): void |
|
73 | { |
||
74 | 36 | $this->copyright(); |
|
75 | |||
76 | 36 | $locale = (string) $this->argument('locale'); |
|
77 | |||
78 | 36 | if ($this->publisher->isDefault($locale)) { |
|
79 | 6 | $this->info("The locale [{$locale}] is a default lang and it's shipped with laravel."); |
|
80 | 6 | $this->line(''); |
|
81 | 6 | return; |
|
82 | } |
||
83 | |||
84 | 30 | $this->publish($locale, [ |
|
85 | 30 | 'force' => (bool) $this->option('force'), |
|
86 | 30 | 'inline' => (bool) $this->option('inline'), |
|
87 | 30 | 'json' => (bool) $this->option('json'), |
|
88 | ]); |
||
89 | |||
90 | 30 | $this->line(''); |
|
91 | 30 | } |
|
92 | |||
93 | /* ----------------------------------------------------------------- |
||
94 | | Other Methods |
||
95 | | ----------------------------------------------------------------- |
||
96 | */ |
||
97 | |||
98 | /** |
||
99 | * Publish the translations. |
||
100 | * |
||
101 | * @param string $locale |
||
102 | * @param array $options |
||
103 | */ |
||
104 | 30 | private function publish(string $locale, array $options): void |
|
113 | |||
114 | /** |
||
115 | * Show the results. |
||
116 | * |
||
117 | * @param array $headers |
||
118 | * @param array $results |
||
119 | */ |
||
120 | 30 | public function showResults(array $headers, array $results): void |
|
129 | } |
||
130 |