-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMessageExtractorOptions.php
More file actions
122 lines (104 loc) · 3.36 KB
/
MessageExtractorOptions.php
File metadata and controls
122 lines (104 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* This file is part of skillshare/formatphp
*
* skillshare/formatphp is open source software: you can distribute
* it and/or modify it under the terms of the MIT License
* (the "License"). You may not use this file except in
* compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* @copyright Copyright (c) Skillshare, Inc. <https://www.skillshare.com>
* @license https://opensource.org/licenses/MIT MIT License
*/
declare(strict_types=1);
namespace FormatPHP\Extractor;
use FormatPHP\Icu\MessageFormat\Manipulator;
/**
* MessageExtractor options
*/
class MessageExtractorOptions
{
private const DEFAULT_FUNCTION_NAMES = ['formatMessage'];
private const DEFAULT_PARSERS = ['php'];
/**
* Formatter name or path to a formatter script that controls the shape
* of the JSON produced for $outFile
*/
public ?string $format = null;
/**
* Target file path to save the JSON output file of all translations
* extracted from the files
*/
public ?string $outFile = null;
/**
* If message descriptors are missing the id property, we will use this
* pattern to automatically generate IDs for them
*
* @see IdInterpolator
*/
public string $idInterpolationPattern = IdInterpolator::DEFAULT_ID_INTERPOLATION_PATTERN;
/**
* Whether to extract metadata for the source files
*
* If true, the extracted descriptors will each include `file`, `start`,
* `end`, `line`, and `col` properties.
*/
public bool $extractSourceLocation = false;
/**
* Whether to throw an exception when failing to process any file in the batch
*
* The default is to emit warnings, while continuing to process the rest
* of the files.
*/
public bool $throws = false;
/**
* Allows parsing of additional custom pragma to include custom metadata in
* the extracted messages
*/
public ?string $pragma = null;
/**
* Whether to preserve whitespace and newlines in extracted messages
*/
public bool $preserveWhitespace = false;
/**
* Whether to hoist selectors and flatten sentences as much as possible
*
* @see Manipulator::hoistSelectors()
*/
public bool $flatten = false;
/**
* Function and method names to parse from the application source code
*
* @var string[]
*/
public array $functionNames = self::DEFAULT_FUNCTION_NAMES;
/**
* Glob file path patterns to ignore
*
* @var string[]
*/
public array $ignore = [];
/**
* Parsers to use for extracting format messages from application source code
*
* @var string[]
*/
public array $parsers = self::DEFAULT_PARSERS;
/**
* Whether to update the source code with by adding auto-generated IDs
* to the descriptors
*
* Any IDs already present in the source code will remain unchanged.
*/
public bool $addGeneratedIdsToSourceCode = false;
/**
* Whether to validate ICU message syntax during extraction
*/
public bool $validateMessages = false;
}