1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helldar\LaravelLangPublisher\Concerns; |
4
|
|
|
|
5
|
|
|
use Helldar\LaravelLangPublisher\Facades\Config; |
6
|
|
|
use Helldar\LaravelLangPublisher\Facades\Path; |
7
|
|
|
|
8
|
|
|
trait Pathable |
9
|
|
|
{ |
10
|
24 |
|
protected function pathSource(string $package, string $locale): string |
11
|
|
|
{ |
12
|
24 |
|
$this->log('Retrieving a link to the source directory for the', $package, 'package and the', $locale, 'localization...'); |
|
|
|
|
13
|
|
|
|
14
|
24 |
|
return Path::source($package, $locale); |
15
|
|
|
} |
16
|
|
|
|
17
|
24 |
|
protected function pathTarget(string $locale, bool $is_json = false): string |
18
|
|
|
{ |
19
|
24 |
|
$this->log('Retrieving a link to the target directory for the', $locale, '(is json:', $is_json, ') localization...'); |
20
|
|
|
|
21
|
24 |
|
return Path::target($locale, $is_json); |
22
|
|
|
} |
23
|
|
|
|
24
|
15 |
|
protected function pathTargetFull(string $locale, ?string $filename): string |
25
|
|
|
{ |
26
|
15 |
|
$this->log('Retrieving a link to the target file for the', $locale, 'localization, filename is ', $filename, '...'); |
27
|
|
|
|
28
|
15 |
|
return Path::targetFull($locale, $filename); |
29
|
|
|
} |
30
|
|
|
|
31
|
19 |
|
protected function pathLocales(string $package, string $locale = null): string |
32
|
|
|
{ |
33
|
19 |
|
$this->log('Getting the path to excluding English localization: ' . $locale); |
34
|
|
|
|
35
|
19 |
|
return Path::locales($package, $locale); |
36
|
|
|
} |
37
|
|
|
|
38
|
24 |
|
protected function pathVendor(): string |
39
|
|
|
{ |
40
|
24 |
|
$this->log('Getting the vendor path.'); |
41
|
|
|
|
42
|
24 |
|
return Config::basePath(); |
43
|
|
|
} |
44
|
|
|
|
45
|
14 |
|
protected function pathDirectory(string $path): ?string |
46
|
|
|
{ |
47
|
14 |
|
$this->log('Getting file directory:', $path); |
48
|
|
|
|
49
|
14 |
|
$directory = Path::directory($path); |
50
|
|
|
|
51
|
14 |
|
return $directory !== '.' ? $directory : null; |
52
|
|
|
} |
53
|
|
|
|
54
|
14 |
|
protected function pathFilename(string $path): string |
55
|
|
|
{ |
56
|
14 |
|
$this->log('Getting file name without extension:', $path); |
57
|
|
|
|
58
|
14 |
|
return Path::filename($path); |
59
|
|
|
} |
60
|
|
|
|
61
|
14 |
|
protected function pathExtension(string $path): string |
62
|
|
|
{ |
63
|
14 |
|
$this->log('Getting file extension:', $path); |
64
|
|
|
|
65
|
14 |
|
return Path::extension($path); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|