info('Translating ' . $locale . ' for ' . $file . ', please wait...'); $results = []; $localeFile = File::get($filePath); $localeFileContent = array_keys(json_decode($localeFile, true)); $translator = new GoogleTranslate($locale); $translator->setSource(config('app.fallback_locale')); foreach ($localeFileContent as $key) { $results[$key] = $translator->translate($key); } File::put($filePath, json_encode($results, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { $this->error('Error: ' . $e->getMessage()); } } } return 0; } }