|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the PHP Translation package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) PHP Translation team <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Translation\Bundle\Model; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* This class is a PHP representation of `translation.configs.xxx`. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Tobias Nyholm <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
final class Configuration |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
private $name; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
private $locales; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Usually dirname('kernel.project_dir'). |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private $projectRoot; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* This is where we dump all translations. |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $outputDir; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* The absolute path to folders we scan for translations. |
|
47
|
|
|
* |
|
48
|
|
|
* @var array |
|
49
|
|
|
*/ |
|
50
|
|
|
private $dirs; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Directories we should not extract translations from. |
|
54
|
|
|
* |
|
55
|
|
|
* @var array |
|
56
|
|
|
*/ |
|
57
|
|
|
private $excludedDirs; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* File names we should not extract translations from. |
|
61
|
|
|
* |
|
62
|
|
|
* @var array |
|
63
|
|
|
*/ |
|
64
|
|
|
private $excludedNames; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Directories that holds translation files but is out of our control. |
|
68
|
|
|
* |
|
69
|
|
|
* @var array |
|
70
|
|
|
*/ |
|
71
|
|
|
private $externalTranslationsDirs; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* The format we store translation files in. |
|
75
|
|
|
* |
|
76
|
|
|
* @var string |
|
77
|
|
|
*/ |
|
78
|
|
|
private $outputFormat; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @var array |
|
82
|
|
|
*/ |
|
83
|
|
|
private $blacklistDomains; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @var array |
|
87
|
|
|
*/ |
|
88
|
|
|
private $whitelistDomains; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @var string |
|
92
|
|
|
*/ |
|
93
|
|
|
private $xliffVersion; |
|
94
|
|
|
|
|
95
|
7 |
|
public function __construct(array $data) |
|
96
|
|
|
{ |
|
97
|
7 |
|
$this->name = $data['name']; |
|
98
|
7 |
|
$this->locales = $data['locales']; |
|
99
|
7 |
|
$this->projectRoot = $data['project_root']; |
|
100
|
7 |
|
$this->outputDir = $data['output_dir']; |
|
101
|
7 |
|
$this->dirs = $data['dirs']; |
|
102
|
7 |
|
$this->excludedDirs = $data['excluded_dirs']; |
|
103
|
7 |
|
$this->excludedNames = $data['excluded_names']; |
|
104
|
7 |
|
$this->externalTranslationsDirs = $data['external_translations_dirs']; |
|
105
|
7 |
|
$this->outputFormat = $data['output_format']; |
|
106
|
7 |
|
$this->blacklistDomains = $data['blacklist_domains']; |
|
107
|
7 |
|
$this->whitelistDomains = $data['whitelist_domains']; |
|
108
|
7 |
|
$this->xliffVersion = $data['xliff_version']; |
|
109
|
7 |
|
} |
|
110
|
|
|
|
|
111
|
1 |
|
public function getName(): string |
|
112
|
|
|
{ |
|
113
|
1 |
|
return $this->name; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
1 |
|
public function getLocales(): array |
|
117
|
|
|
{ |
|
118
|
1 |
|
return $this->locales; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
1 |
|
public function getProjectRoot(): string |
|
122
|
|
|
{ |
|
123
|
1 |
|
return $this->projectRoot; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
2 |
|
public function getOutputDir(): string |
|
127
|
|
|
{ |
|
128
|
2 |
|
return $this->outputDir; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
1 |
|
public function getDirs(): array |
|
132
|
|
|
{ |
|
133
|
1 |
|
return $this->dirs; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
1 |
|
public function getExcludedDirs(): array |
|
137
|
|
|
{ |
|
138
|
1 |
|
return $this->excludedDirs; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
1 |
|
public function getExcludedNames(): array |
|
142
|
|
|
{ |
|
143
|
1 |
|
return $this->excludedNames; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
1 |
|
public function getExternalTranslationsDirs(): array |
|
147
|
|
|
{ |
|
148
|
1 |
|
return $this->externalTranslationsDirs; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
1 |
|
public function getOutputFormat(): string |
|
152
|
|
|
{ |
|
153
|
1 |
|
return $this->outputFormat; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
1 |
|
public function getBlacklistDomains(): array |
|
157
|
|
|
{ |
|
158
|
1 |
|
return $this->blacklistDomains; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
1 |
|
public function getWhitelistDomains(): array |
|
162
|
|
|
{ |
|
163
|
1 |
|
return $this->whitelistDomains; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Get all paths where translation paths are stored. Both external files and |
|
168
|
|
|
* files created by us. |
|
169
|
|
|
*/ |
|
170
|
1 |
|
public function getPathsToTranslationFiles(): array |
|
171
|
|
|
{ |
|
172
|
1 |
|
return \array_merge($this->externalTranslationsDirs, [$this->getOutputDir()]); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
1 |
|
public function getXliffVersion(): string |
|
176
|
|
|
{ |
|
177
|
1 |
|
return $this->xliffVersion; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Reconfigures the directories so we can use one configuration for extracting |
|
182
|
|
|
* the messages only from one bundle. |
|
183
|
|
|
*/ |
|
184
|
|
|
public function reconfigureBundleDirs(string $bundleDir, string $outputDir): void |
|
185
|
|
|
{ |
|
186
|
|
|
$this->dirs = [$bundleDir]; |
|
187
|
|
|
$this->outputDir = $outputDir; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|