1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helldar\LaravelLangPublisher\Support; |
4
|
|
|
|
5
|
|
|
use Helldar\LaravelLangPublisher\Concerns\Logger; |
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
|
|
|
use Logger; |
|
|
|
|
13
|
|
|
|
14
|
|
|
public const KEY_PRIVATE = 'lang-publisher-private'; |
15
|
|
|
|
16
|
|
|
public const KEY_PUBLIC = 'lang-publisher'; |
17
|
|
|
|
18
|
|
|
public function packages(): array |
19
|
|
|
{ |
20
|
|
|
$this->log('Getting a list of supported packages...'); |
21
|
|
|
|
22
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.packages'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Getting the path to the sources of the English localization. |
27
|
|
|
* |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
|
|
public function basePath(): string |
31
|
|
|
{ |
32
|
|
|
$this->log('Getting the path to the sources of the English localization...'); |
33
|
|
|
|
34
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.base'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Getting the path to source locale. |
39
|
|
|
* |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public function sourcePath(): string |
43
|
|
|
{ |
44
|
|
|
$this->log('Getting the path to source locale...'); |
45
|
|
|
|
46
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.source'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Getting the path to localizations. |
51
|
|
|
* |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
public function localesPath(): string |
55
|
|
|
{ |
56
|
|
|
$this->log('Getting the path to localizations...'); |
57
|
|
|
|
58
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.locales'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Getting the path to resources of the application. |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function resourcesPath(): string |
67
|
|
|
{ |
68
|
|
|
$this->log('Getting the path to resources of the application...'); |
69
|
|
|
|
70
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.target'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Determines what type of files to use when updating language files. |
75
|
|
|
* |
76
|
|
|
* @return bool |
77
|
|
|
*/ |
78
|
|
|
public function hasInline(): bool |
79
|
|
|
{ |
80
|
|
|
$this->log('Determines what type of files to use when updating language files...'); |
81
|
|
|
|
82
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.inline'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Determines whether values should be aligned when saving. |
87
|
|
|
* |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function hasAlignment(): bool |
91
|
|
|
{ |
92
|
|
|
$this->log('Determines whether values should be aligned when saving...'); |
93
|
|
|
|
94
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.alignment'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Key exclusion when combining. |
99
|
|
|
* |
100
|
|
|
* @return array |
101
|
|
|
*/ |
102
|
|
|
public function excludes(): array |
103
|
|
|
{ |
104
|
|
|
$this->log('Key exclusion when combining...'); |
105
|
|
|
|
106
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.exclude', []); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* List of ignored localizations. |
111
|
|
|
* |
112
|
|
|
* @return array |
113
|
|
|
*/ |
114
|
|
|
public function ignores(): array |
115
|
|
|
{ |
116
|
|
|
$this->log('List of ignored localizations...'); |
117
|
|
|
|
118
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.ignore', []); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Getting the value of the option to change the case of keys. |
123
|
|
|
* |
124
|
|
|
* @return int |
125
|
|
|
*/ |
126
|
|
|
public function getCase(): int |
127
|
|
|
{ |
128
|
|
|
$this->log('Getting the value of the option to change the case of keys...'); |
129
|
|
|
|
130
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.case', Caseable::NO_CASE); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Getting the default localization name. |
135
|
|
|
* |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
|
public function defaultLocale(): string |
139
|
|
|
{ |
140
|
|
|
$this->log('Getting the default localization name...'); |
141
|
|
|
|
142
|
|
|
return Illuminate::get('app.locale') ?: $this->fallbackLocale(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Getting the fallback localization name. |
147
|
|
|
* |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
public function fallbackLocale(): string |
151
|
|
|
{ |
152
|
|
|
$this->log('Getting the fallback localization name...'); |
153
|
|
|
|
154
|
|
|
return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|