Skip to content

Commit

Permalink
Update LangCommand.php
Browse files Browse the repository at this point in the history
  • Loading branch information
GIGABAIT93 committed Feb 22, 2023
1 parent 88d75a2 commit 8a98a23
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Commands/LangCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 8a98a23

Please sign in to comment.