option('type') ?? 'export'; if ($type == 'import') { $this->import(); } if ($type == 'export') { $this->export(); } } private function import() { //loop and foreach ($this->langs as $lang) { $import_file = "textsphp_{$lang}.php"; $dir = $this->option('path') ?? storage_path('lang_import/'); $path = $dir.$import_file; if (file_exists($path)) { $this->logMessage($path); $trans = file_get_contents($path); file_put_contents(lang_path("/{$lang}/texts.php"), $trans); } else { $this->logMessage("Could not open file"); $this->logMessage($path); } } } private function export() { Storage::disk('local')->makeDirectory('lang'); foreach ($this->langs as $lang) { nlog($lang); Storage::disk('local')->makeDirectory("lang/{$lang}"); $translations = Lang::getLoader()->load($lang, 'texts'); nlog($translations); Storage::disk('local')->put("lang/{$lang}/{$lang}.json", json_encode(Arr::dot($translations), JSON_UNESCAPED_UNICODE)); } } private function logMessage($str) { $str = date('Y-m-d h:i:s').' '.$str; $this->info($str); $this->log .= $str."\n"; } }