From 8a98a238025c60c916cbd31f0e99a5ed6441340a Mon Sep 17 00:00:00 2001 From: GIGABAIT93 Date: Wed, 22 Feb 2023 20:08:09 +0200 Subject: [PATCH] Update LangCommand.php --- src/Commands/LangCommand.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Commands/LangCommand.php b/src/Commands/LangCommand.php index 032b37f..dded147 100644 --- a/src/Commands/LangCommand.php +++ b/src/Commands/LangCommand.php @@ -62,7 +62,7 @@ private function import() foreach ($this->getExistLocalization() as $key => $value) { $file = $value . self::SEP . 'billing' . self::SEP . 'client.php'; if (!file_exists($file)) { - $content = file_get_contents("https://raw.githubusercontent.com/Mubeen142/billing-docs/main/lang/{$key}/billing/client.php"); + $content = $this->getGitContent($key); if (strlen($content) > 100) { file_put_contents($file, $content); $this->info("The localization {$this->languages()[$key]} was found on GITHUB and added"); @@ -71,8 +71,8 @@ private function import() File::copy($this->default_file, $file); $this->info("The localization {$this->languages()[$key]} was generated with a standard translation"); } else { - $this->info("Update localization {$this->languages()[$key]}"); - $this->updateLocalization($file); + $this->info("Update localization {$this->languages()[$key]}"); + $this->updateLocalization($file); } } $this->info("Import done"); @@ -88,7 +88,7 @@ private function generate() $file = $this->lang_path . self::SEP . $code . self::SEP . 'billing' . self::SEP . 'client.php'; if (!file_exists($file)) { $this->copyDirectory($this->lang_path . self::SEP . 'en', $this->lang_path . self::SEP . $code); - $content = file_get_contents("https://raw.githubusercontent.com/Mubeen142/billing-docs/main/lang/{$code}/billing/client.php"); + $content = $this->getGitContent($code); if (strlen($content) > 100) { file_put_contents($file, $content); $this->info("The localization {$this->languages()[$code]} was found on GITHUB and added"); @@ -160,4 +160,13 @@ private function updateLocalization($edit_locale_path) return; } + private function getGitContent($code) + { + try { + $content = file_get_contents("https://raw.githubusercontent.com/Mubeen142/billing-docs/main/lang/{$code}/billing/client.php"); + } catch (\Throwable$th) { + $content = ''; + } + return $content; + } }