1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Printful\GettextCms\Structures; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class represents a single translation message for saving to or receiving from storage |
7
|
|
|
*/ |
8
|
|
|
class MessageItem |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Unique 32 char identifier for this message, should be used as the unique key |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
public $key = ''; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
public $locale = ''; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $domain = ''; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
public $context = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public $original = ''; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $translation = ''; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Is translation gone from source |
44
|
|
|
* @var bool |
45
|
|
|
*/ |
46
|
|
|
public $isDisabled = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* This indicates if original is translated, but plural translations can be missing. |
50
|
|
|
* This means that we still can use this translation for gettext (message should be exported), |
51
|
|
|
* just plurals won't have a translation. |
52
|
|
|
* |
53
|
|
|
* @var bool |
54
|
|
|
*/ |
55
|
|
|
public $hasOriginalTranslation = false; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* This indicates if string has to be translated/checked, can be missing plural translation |
59
|
|
|
* @var bool |
60
|
|
|
*/ |
61
|
|
|
public $requiresTranslating = false; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
public $originalPlural = ''; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* List of plural translations |
70
|
|
|
* |
71
|
|
|
* @var string[] |
72
|
|
|
*/ |
73
|
|
|
public $pluralTranslations = []; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* List of pathnames where this translation exists (with line numbers) |
77
|
|
|
* |
78
|
|
|
* @var array[] [[file, line], ..] |
79
|
|
|
*/ |
80
|
|
|
public $references = []; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Comments from the translator |
84
|
|
|
* @var string[] |
85
|
|
|
*/ |
86
|
|
|
public $comments = []; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Comments from programmer (extracted from source code) |
90
|
|
|
* @var string[] |
91
|
|
|
*/ |
92
|
|
|
public $extractedComments = []; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Indicates if this is a translation in JS file |
96
|
|
|
* |
97
|
|
|
* Sometimes we have to know which translations are present in JS files |
98
|
|
|
* so we export them separately for client side usage. |
99
|
|
|
* |
100
|
|
|
* This is detected from message references (if comes from vue or js files) |
101
|
|
|
* |
102
|
|
|
* @var bool |
103
|
|
|
*/ |
104
|
|
|
public $isInJs = false; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Indicates if this is a dynamically created translation |
108
|
|
|
* |
109
|
|
|
* @var bool |
110
|
|
|
*/ |
111
|
|
|
public $isDynamic = false; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Indicates if this is a translation that is found in a file |
115
|
|
|
* |
116
|
|
|
* @var bool |
117
|
|
|
*/ |
118
|
|
|
public $isInFile = false; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* If this is an existing translation that was saved to repository |
122
|
|
|
* |
123
|
|
|
* @return bool |
124
|
|
|
*/ |
125
|
33 |
|
public function exists(): bool |
126
|
|
|
{ |
127
|
33 |
|
return !!$this->key; |
128
|
|
|
} |
129
|
|
|
} |