|
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 basePath(): string |
|
19
|
|
|
{ |
|
20
|
|
|
$this->log('Getting the path to the sources of the English localization...'); |
|
21
|
48 |
|
|
|
22
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.base'); |
|
23
|
48 |
|
} |
|
24
|
|
|
|
|
25
|
48 |
|
public function localesPath(): string |
|
26
|
|
|
{ |
|
27
|
|
|
$this->log('Getting the path to localizations...'); |
|
28
|
|
|
|
|
29
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.locales'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function resourcesPath(): string |
|
33
|
48 |
|
{ |
|
34
|
|
|
$this->log('Getting the path to resources...'); |
|
35
|
48 |
|
|
|
36
|
|
|
return Illuminate::get(self::KEY_PRIVATE . '.path.target'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function hasInline(): bool |
|
40
|
|
|
{ |
|
41
|
|
|
$this->log('Determines what type of files to use when updating language files...'); |
|
42
|
|
|
|
|
43
|
15 |
|
return Illuminate::get(self::KEY_PUBLIC . '.inline'); |
|
44
|
|
|
} |
|
45
|
15 |
|
|
|
46
|
|
|
public function hasAlignment(): bool |
|
47
|
|
|
{ |
|
48
|
|
|
$this->log('Do arrays need to be aligned by keys before processing arrays?'); |
|
49
|
|
|
|
|
50
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.alignment'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
13 |
|
public function excludes(): array |
|
54
|
|
|
{ |
|
55
|
13 |
|
$this->log('Key exclusion when combining...'); |
|
56
|
|
|
|
|
57
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.exclude', []); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function ignores(): array |
|
61
|
|
|
{ |
|
62
|
|
|
$this->log('List of ignored localizations...'); |
|
63
|
|
|
|
|
64
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.ignore', []); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getCase(): int |
|
68
|
48 |
|
{ |
|
69
|
|
|
$this->log('Getting the value of the option to change the case of keys...'); |
|
70
|
48 |
|
|
|
71
|
|
|
return Illuminate::get(self::KEY_PUBLIC . '.case', Caseable::NO_CASE); |
|
72
|
48 |
|
} |
|
73
|
35 |
|
|
|
74
|
48 |
|
public function defaultLocale(): string |
|
75
|
|
|
{ |
|
76
|
|
|
$this->log('Obtaining a default localization key...'); |
|
77
|
48 |
|
|
|
78
|
|
|
return Illuminate::get('app.locale') ?: $this->fallbackLocale(); |
|
79
|
48 |
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function fallbackLocale(): string |
|
82
|
|
|
{ |
|
83
|
|
|
$this->log('Obtaining a fallback localization key...'); |
|
84
|
|
|
|
|
85
|
|
|
return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|