public function fillKeys($fileName, array $keys)
{
$appends = [];
foreach ($keys as $key => $values) {
foreach ($values as $languageKey => $value) {
$filePath = $this->path . "/{$languageKey}/{$fileName}.php";
Arr::set($appends[$filePath], $key, $value);
}
}
foreach ($appends as $filePath => $values) {
$fileContent = $this->getFileContent($filePath, true);
$newContent = array_replace_recursive($fileContent, $values);
$this->writeFile($filePath, $newContent);
}
}
/** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Looking for missing translations...'); $languages = $this->manager->languages(); $missing = $this->getMissing($languages); $values = $this->collectValues($missing); $input = []; foreach ($values as $key => $value) { preg_match('/^([^\\.]*)\\.(.*):(.*)/', $key, $matches); $input[$matches[1]][$matches[2]][$matches[3]] = $value; $this->line("\"<fg=yellow>{$key}</>\" was set to \"<fg=yellow>{$value}</>\" successfully."); } foreach ($input as $fileName => $values) { $this->manager->fillKeys($fileName, $values); } $this->info('Done!'); }