Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
35 | public function translate(array $texts): array |
||
36 | { |
||
37 | $response = $this->translationServiceClient->translateText( |
||
38 | $texts, |
||
39 | $this->languageTo, |
||
40 | TranslationServiceClient::locationName($this->projectId, 'global'), |
||
41 | [ |
||
42 | 'sourceLanguageCode' => $this->languageFrom, |
||
43 | ] |
||
44 | ); |
||
45 | |||
46 | $translations = []; |
||
47 | foreach ($response->getTranslations() as $translation) { |
||
48 | $translations[] = html_entity_decode($translation->getTranslatedText()); |
||
49 | } |
||
50 | |||
51 | return array_combine($texts, $translations); |
||
52 | } |
||
54 |