@@ -19,6 +19,9 @@ class Translation
1919 protected $ flags ;
2020 protected $ comments ;
2121 protected $ extractedComments ;
22+ protected $ previousContext ;
23+ protected $ previousOriginal ;
24+ protected $ previousPlural ;
2225
2326 public static function create (?string $ context , string $ original ): Translation
2427 {
@@ -64,6 +67,9 @@ public function toArray(): array
6467 'plural ' => $ this ->plural ,
6568 'pluralTranslations ' => $ this ->pluralTranslations ,
6669 'disabled ' => $ this ->disabled ,
70+ 'previousContext ' => $ this ->previousContext ,
71+ 'previousOriginal ' => $ this ->previousOriginal ,
72+ 'previousPlural ' => $ this ->previousPlural ,
6773 'references ' => $ this ->getReferences ()->toArray (),
6874 'flags ' => $ this ->getFlags ()->toArray (),
6975 'comments ' => $ this ->getComments ()->toArray (),
@@ -116,6 +122,42 @@ public function getPlural(): ?string
116122 return $ this ->plural ;
117123 }
118124
125+ public function setPreviousOriginal (?string $ previousOriginal ): self
126+ {
127+ $ this ->previousOriginal = $ previousOriginal ;
128+
129+ return $ this ;
130+ }
131+
132+ public function getPreviousOriginal (): ?string
133+ {
134+ return $ this ->previousOriginal ;
135+ }
136+
137+ public function setPreviousContext (?string $ previousContext ): self
138+ {
139+ $ this ->previousContext = $ previousContext ;
140+
141+ return $ this ;
142+ }
143+
144+ public function getPreviousContext (): ?string
145+ {
146+ return $ this ->previousContext ;
147+ }
148+
149+ public function setPreviousPlural (?string $ previousPlural ): self
150+ {
151+ $ this ->previousPlural = $ previousPlural ;
152+
153+ return $ this ;
154+ }
155+
156+ public function getPreviousPlural (): ?string
157+ {
158+ return $ this ->previousPlural ;
159+ }
160+
119161 public function disable (bool $ disabled = true ): self
120162 {
121163 $ this ->disabled = $ disabled ;
@@ -225,6 +267,18 @@ public function mergeWith(Translation $translation, int $strategy = 0): Translat
225267 $ merged ->plural = $ translation ->plural ;
226268 }
227269
270+ if (!$ merged ->previousContext || ($ translation ->previousContext && $ override )) {
271+ $ merged ->previousContext = $ translation ->previousContext ;
272+ }
273+
274+ if (!$ merged ->previousOriginal || ($ translation ->previousOriginal && $ override )) {
275+ $ merged ->previousOriginal = $ translation ->previousOriginal ;
276+ }
277+
278+ if (!$ merged ->previousPlural || ($ translation ->previousPlural && $ override )) {
279+ $ merged ->previousPlural = $ translation ->previousPlural ;
280+ }
281+
228282 if (empty ($ merged ->pluralTranslations ) || (!empty ($ translation ->pluralTranslations ) && $ override )) {
229283 $ merged ->pluralTranslations = $ translation ->pluralTranslations ;
230284 }
0 commit comments