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