@@ 90-106 (lines=17) @@ | ||
87 | 'name' => $message->getDomain().'::'.$message->getKey(), |
|
88 | ]); |
|
89 | ||
90 | foreach ($result as $key) { |
|
91 | if ($key->getName() === $message->getDomain().'::'.$message->getKey()) { |
|
92 | /* @var Index $index */ |
|
93 | $index = $this->client->translation()->indexKey($this->projectId, $key->getId(), ['tags' => $message->getDomain()]); |
|
94 | foreach ($index as $translation) { |
|
95 | if ($translation->getLocale()->getId() === $localeId) { |
|
96 | // Translation does already exist |
|
97 | return; |
|
98 | } |
|
99 | } |
|
100 | ||
101 | // Create a translation with an existing key |
|
102 | $this->client->translation()->create($this->projectId, $localeId, $key->getId(), $message->getTranslation()); |
|
103 | ||
104 | return; |
|
105 | } |
|
106 | } |
|
107 | ||
108 | try { |
|
109 | /* @var KeyCreated $keyCreated */ |
|
@@ 138-158 (lines=21) @@ | ||
135 | 'name' => $message->getDomain().'::'.$message->getKey() |
|
136 | ]); |
|
137 | ||
138 | foreach ($results as $searchResult) { |
|
139 | if ($searchResult->getName() === $message->getDomain().'::'.$message->getKey()) { |
|
140 | ||
141 | /* @var Index $translations */ |
|
142 | $translations = $this->client->translation()->indexKey($this->projectId, $searchResult->getId(), [ |
|
143 | 'tags' => $message->getDomain(), |
|
144 | ]); |
|
145 | ||
146 | foreach ($translations as $translation) { |
|
147 | if ($translation->getLocale()->getId() === $localeId) { |
|
148 | $this->client->translation()->update( |
|
149 | $this->projectId, |
|
150 | $translation->getId(), |
|
151 | $message->getTranslation() |
|
152 | ); |
|
153 | ||
154 | return; |
|
155 | } |
|
156 | } |
|
157 | } |
|
158 | } |
|
159 | ||
160 | // No translation was found, lets create one. |
|
161 | $this->create($message); |