Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HichemTab-tech committed Aug 4, 2023
1 parent 15aeb09 commit fe93a1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hichemtab-tech/langify-laravel",
"version": "1.0.7",
"version": "1.0.8",
"description": "LangifyLaravel is a powerful Laravel language generation library that automates the process of creating language files for multilingual support. With just one language file, it generates translations for multiple languages, making localization a breeze.",
"keywords": [
"multilingual",
Expand Down
8 changes: 7 additions & 1 deletion src/Console/Commands/GenerateLangs.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function handle(): void
foreach ($result as $lang => $data) {
foreach ($data as $key => $value) {
$replacements = [
'{{CONTENT}}' => var_export($value, true),
'{{CONTENT}}' => $this->var_export_with_square_brackets(var_export($value, true)),
];
$template = File::get(__DIR__.'/stubs/langPlaceholder.stub');
$generatedClass = str_replace(array_keys($replacements), array_values($replacements), $template);
Expand All @@ -110,4 +110,10 @@ public function handle(): void
}
$this->info("Done!");
}

function var_export_with_square_brackets($expression): array|string|null
{
$expression = preg_replace('/^array\s\(/', '[', $expression);
return preg_replace('/\)$/', ']', $expression);
}
}

0 comments on commit fe93a1f

Please sign in to comment.