diff --git a/src/Drivers/Translation.php b/src/Drivers/Translation.php index e7c8483..c8e1a19 100644 --- a/src/Drivers/Translation.php +++ b/src/Drivers/Translation.php @@ -70,7 +70,6 @@ public function autoTranslate($language = false) } /** - * * Translate text using Google Translate * * @param $language @@ -79,7 +78,7 @@ public function autoTranslate($language = false) * @throws \ErrorException */ public function getGoogleTranslate($language,$token){ - $tr = new GoogleTranslate($language); + $tr = new GoogleTranslate($language, $this->sourceLanguage); return $tr->translate($token); } @@ -89,12 +88,19 @@ public function getGoogleTranslate($language,$token){ * @param $language */ public function translateLanguage($language){ + //No need to translate e.g. English to English + if ($language === $this->sourceLanguage) { + return; + } + $translations = $this->getSourceLanguageTranslationsWith($language); foreach ($translations as $type => $groups) { foreach ($groups as $group => $translations) { foreach ($translations as $key => $value) { - $sourceLanguageValue = $value[$this->sourceLanguage]; + //Value will be empty if it's found in the app source code but not in the source language files + //We fall back to $key in that case + $sourceLanguageValue = in_array($value[$this->sourceLanguage], ["", null]) ? $key : $value[$this->sourceLanguage]; $targetLanguageValue = $value[$language]; if (in_array($targetLanguageValue, ["", null])) {