@@ -78,8 +78,8 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
78
78
$ this ->convertSourceLocationsToMessages ($ target , $ sourceCollection , $ catalogue );
79
79
80
80
// Remove all SourceLocation and State form catalogue.
81
- foreach ($ catalogue-> getDomains ( ) as $ domain ) {
82
- foreach ($ catalogue -> all ( $ domain ) as $ key => $ translation ) {
81
+ foreach (NSA :: getProperty ( $ catalogue, ' messages ' ) as $ domain => $ translations ) {
82
+ foreach ($ translations as $ key => $ translation ) {
83
83
$ meta = $ this ->getMetadata ($ catalogue , $ key , $ domain );
84
84
$ meta ->removeAllInCategory ('file-source ' );
85
85
$ meta ->removeAllInCategory ('state ' );
@@ -91,28 +91,36 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
91
91
$ result = $ merge ->getResult ();
92
92
$ domains = $ merge ->getDomains ();
93
93
94
+ $ resultMessages = NSA ::getProperty ($ result , 'messages ' );
95
+
94
96
// Mark new messages as new/obsolete
95
97
foreach ($ domains as $ domain ) {
98
+ $ intlDomain = $ domain . '+intl-icu ' /* MessageCatalogueInterface::INTL_DOMAIN_SUFFIX */ ;
99
+
96
100
foreach ($ merge ->getNewMessages ($ domain ) as $ key => $ translation ) {
97
- $ meta = $ this ->getMetadata ($ result , $ key , $ domain );
101
+ $ messageDomain = array_key_exists ($ key , $ resultMessages [$ intlDomain ] ?? []) ? $ intlDomain : $ domain ;
102
+
103
+ $ meta = $ this ->getMetadata ($ result , $ key , $ messageDomain );
98
104
$ meta ->setState ('new ' );
99
- $ this ->setMetadata ($ result , $ key , $ domain , $ meta );
105
+ $ this ->setMetadata ($ result , $ key , $ messageDomain , $ meta );
100
106
101
107
// Add custom translations that we found in the source
102
108
if (null === $ translation ) {
103
109
if (null !== $ newTranslation = $ meta ->getTranslation ()) {
104
- $ result ->set ($ key , $ newTranslation , $ domain );
110
+ $ result ->set ($ key , $ newTranslation , $ messageDomain );
105
111
// We do not want "translation" key stored anywhere.
106
112
$ meta ->removeAllInCategory ('translation ' );
107
113
} elseif (null !== ($ newTranslation = $ meta ->getDesc ()) && $ catalogue ->getLocale () === $ this ->defaultLocale ) {
108
- $ result ->set ($ key , $ newTranslation , $ domain );
114
+ $ result ->set ($ key , $ newTranslation , $ messageDomain );
109
115
}
110
116
}
111
117
}
112
118
foreach ($ merge ->getObsoleteMessages ($ domain ) as $ key => $ translation ) {
113
- $ meta = $ this ->getMetadata ($ result , $ key , $ domain );
119
+ $ messageDomain = array_key_exists ($ key , $ resultMessages [$ intlDomain ] ?? []) ? $ intlDomain : $ domain ;
120
+
121
+ $ meta = $ this ->getMetadata ($ result , $ key , $ messageDomain );
114
122
$ meta ->setState ('obsolete ' );
115
- $ this ->setMetadata ($ result , $ key , $ domain , $ meta );
123
+ $ this ->setMetadata ($ result , $ key , $ messageDomain , $ meta );
116
124
}
117
125
}
118
126
$ results [] = $ result ;
0 commit comments