1414 */
1515class Translations implements Countable, IteratorAggregate
1616{
17+ protected $ description ;
1718 protected $ translations = [];
1819 protected $ headers ;
20+ protected $ flags ;
1921
2022 public static function create (string $ domain = null , string $ language = null ): Translations
2123 {
@@ -35,6 +37,7 @@ public static function create(string $domain = null, string $language = null): T
3537 protected function __construct ()
3638 {
3739 $ this ->headers = new Headers ();
40+ $ this ->flags = new Flags ();
3841 }
3942
4043 public function __clone ()
@@ -46,10 +49,29 @@ public function __clone()
4649 $ this ->headers = clone $ this ->headers ;
4750 }
4851
52+ public function setDescription (?string $ description ): self
53+ {
54+ $ this ->description = $ description ;
55+
56+ return $ this ;
57+ }
58+
59+ public function getDescription (): ?string
60+ {
61+ return $ this ->description ;
62+ }
63+
64+ public function getFlags (): Flags
65+ {
66+ return $ this ->flags ;
67+ }
68+
4969 public function toArray (): array
5070 {
5171 return [
72+ 'description ' => $ this ->description ,
5273 'headers ' => $ this ->headers ->toArray (),
74+ 'flags ' => $ this ->flags ->toArray (),
5375 'translations ' => array_map (
5476 function ($ translation ) {
5577 return $ translation ->toArray ();
@@ -163,6 +185,16 @@ public function mergeWith(Translations $translations, int $strategy = 0): Transl
163185 $ merged ->headers = $ merged ->headers ->mergeWith ($ translations ->headers );
164186 }
165187
188+ if ($ strategy & Merge::FLAGS_THEIRS ) {
189+ $ merged ->flags = clone $ translations ->flags ;
190+ } elseif (!($ strategy & Merge::FLAGS_OURS )) {
191+ $ merged ->flags = $ merged ->flags ->mergeWith ($ translations ->flags );
192+ }
193+
194+ if (!$ merged ->description ) {
195+ $ merged ->description = $ translations ->description ;
196+ }
197+
166198 foreach ($ translations as $ id => $ translation ) {
167199 if (isset ($ merged ->translations [$ id ])) {
168200 $ translation = $ merged ->translations [$ id ]->mergeWith ($ translation , $ strategy );
0 commit comments