|
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
|
16 |
|
} |
|
24
|
|
|
|
|
25
|
16 |
|
/** |
|
26
|
|
|
* Getting the path to the sources of the English localization. |
|
27
|
16 |
|
* |
|
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
|
7 |
|
} |
|
36
|
|
|
|
|
37
|
7 |
|
/** |
|
38
|
|
|
* Getting the path to source locale. |
|
39
|
7 |
|
* |
|
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
|
16 |
|
} |
|
48
|
|
|
|
|
49
|
16 |
|
/** |
|
50
|
|
|
* Getting the path to localizations. |
|
51
|
16 |
|
* |
|
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
|
11 |
|
} |
|
60
|
|
|
|
|
61
|
11 |
|
/** |
|
62
|
|
|
* Getting the path to resources of the application. |
|
63
|
11 |
|
* |
|
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
|
11 |
|
} |
|
72
|
|
|
|
|
73
|
11 |
|
/** |
|
74
|
|
|
* Determines what type of files to use when updating language files. |
|
75
|
11 |
|
* |
|
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
|
10 |
|
} |
|
84
|
|
|
|
|
85
|
10 |
|
/** |
|
86
|
|
|
* Determines whether values should be aligned when saving. |
|
87
|
10 |
|
* |
|
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
|
10 |
|
} |
|
96
|
|
|
|
|
97
|
10 |
|
/** |
|
98
|
|
|
* Key exclusion when combining. |
|
99
|
10 |
|
* |
|
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
|
11 |
|
} |
|
108
|
|
|
|
|
109
|
11 |
|
/** |
|
110
|
|
|
* List of ignored localizations. |
|
111
|
11 |
|
* |
|
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
|
4 |
|
} |
|
120
|
|
|
|
|
121
|
4 |
|
/** |
|
122
|
|
|
* Getting the value of the option to change the case of keys. |
|
123
|
4 |
|
* |
|
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
|
3 |
|
} |
|
132
|
|
|
|
|
133
|
3 |
|
/** |
|
134
|
|
|
* Getting the default localization name. |
|
135
|
3 |
|
* |
|
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
|
|
|
|