@@ -97,9 +97,15 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
9797 $ meta ->setState ('new ' );
9898 $ this ->setMetadata ($ result , $ key , $ domain , $ meta );
9999
100- // Add "desc" as translation
101- if (null === $ translation && null !== $ desc = $ meta ->getDesc ()) {
102- $ result ->set ($ key , $ desc , $ domain );
100+ // Add custom translations that we found in the source
101+ if (null === $ translation ) {
102+ if (null !== $ newTranslation = $ meta ->getTranslation ()) {
103+ $ result ->set ($ key , $ newTranslation , $ domain );
104+ // We do not want "translation" key stored anywhere.
105+ $ meta ->removeAllInCategory ('translation ' );
106+ } elseif (null !== $ newTranslation = $ meta ->getDesc ()) {
107+ $ result ->set ($ key , $ newTranslation , $ domain );
108+ }
103109 }
104110 }
105111 foreach ($ merge ->getObsoleteMessages ($ domain ) as $ key => $ translation ) {
@@ -138,6 +144,9 @@ private function convertSourceLocationsToMessages(MessageCatalogue $catalogue, S
138144 if (isset ($ sourceLocation ->getContext ()['desc ' ])) {
139145 $ meta ->addCategory ('desc ' , $ sourceLocation ->getContext ()['desc ' ]);
140146 }
147+ if (isset ($ sourceLocation ->getContext ()['translation ' ])) {
148+ $ meta ->addCategory ('translation ' , $ sourceLocation ->getContext ()['translation ' ]);
149+ }
141150 $ this ->setMetadata ($ catalogue , $ key , $ domain , $ meta );
142151 }
143152 }
0 commit comments