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