|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helldar\LaravelLangPublisher\Support; |
|
4
|
|
|
|
|
5
|
|
|
use Helldar\LaravelLangPublisher\Constants\Config as ConfigNames; |
|
6
|
|
|
use Helldar\LaravelLangPublisher\Constants\Locales as LocalesList; |
|
7
|
|
|
use Helldar\PrettyArray\Contracts\Caseable; |
|
8
|
|
|
use Illuminate\Support\Facades\Config as Illuminate; |
|
9
|
|
|
|
|
10
|
|
|
final class Config |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Getting a list of packages from which to synchronize localization files. |
|
14
|
|
|
* |
|
15
|
|
|
* @return array |
|
16
|
|
|
*/ |
|
17
|
|
|
public function packages(): array |
|
18
|
|
|
{ |
|
19
|
|
|
return $this->getList('packages'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
40 |
|
* Getting a list of plugins from which to synchronize localization files. |
|
24
|
|
|
* |
|
25
|
40 |
|
* @return array |
|
26
|
|
|
*/ |
|
27
|
40 |
|
public function plugins(): array |
|
28
|
40 |
|
{ |
|
29
|
|
|
return $this->getList('plugins'); |
|
30
|
40 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function vendor(): string |
|
33
|
30 |
|
{ |
|
34
|
|
|
return Illuminate::get($this->privateKey() . '.path.base'); |
|
35
|
30 |
|
} |
|
36
|
|
|
|
|
37
|
30 |
|
public function resources(): string |
|
38
|
30 |
|
{ |
|
39
|
|
|
return Illuminate::get($this->privateKey() . '.path.target'); |
|
40
|
30 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function source(): string |
|
43
|
|
|
{ |
|
44
|
|
|
return Illuminate::get($this->privateKey() . '.path.source'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function locales(): string |
|
48
|
43 |
|
{ |
|
49
|
|
|
return Illuminate::get($this->privateKey() . '.path.locales'); |
|
50
|
43 |
|
} |
|
51
|
|
|
|
|
52
|
43 |
|
public function excludes(): array |
|
53
|
|
|
{ |
|
54
|
|
|
return Illuminate::get($this->publicKey() . '.exclude', []); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function ignores(): array |
|
58
|
|
|
{ |
|
59
|
|
|
return Illuminate::get($this->publicKey() . '.ignore', []); |
|
60
|
43 |
|
} |
|
61
|
|
|
|
|
62
|
43 |
|
public function getCase(): int |
|
63
|
|
|
{ |
|
64
|
43 |
|
return Illuminate::get($this->publicKey() . '.case', Caseable::NO_CASE); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function defaultLocale(): string |
|
68
|
|
|
{ |
|
69
|
|
|
return Illuminate::get('app.locale') ?: $this->fallbackLocale(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
36 |
|
public function fallbackLocale(): string |
|
73
|
|
|
{ |
|
74
|
36 |
|
return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH; |
|
75
|
|
|
} |
|
76
|
36 |
|
|
|
77
|
|
|
public function hasInline(): bool |
|
78
|
|
|
{ |
|
79
|
|
|
return Illuminate::get($this->publicKey() . '.inline'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function hasAlignment(): bool |
|
83
|
|
|
{ |
|
84
|
43 |
|
return Illuminate::get($this->publicKey() . '.alignment'); |
|
85
|
|
|
} |
|
86
|
43 |
|
|
|
87
|
|
|
protected function getList(string $key): array |
|
88
|
43 |
|
{ |
|
89
|
|
|
$private = Illuminate::get($this->privateKey() . '.' . $key, []); |
|
90
|
|
|
$public = Illuminate::get($this->publicKey() . '.' . $key, []); |
|
91
|
|
|
|
|
92
|
|
|
return array_values(array_merge($private, $public)); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
protected function privateKey(): string |
|
96
|
30 |
|
{ |
|
97
|
|
|
return ConfigNames::KEY_PRIVATE; |
|
98
|
30 |
|
} |
|
99
|
|
|
|
|
100
|
30 |
|
protected function publicKey(): string |
|
101
|
|
|
{ |
|
102
|
|
|
return ConfigNames::KEY_PUBLIC; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|