Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit fe93a1f

Browse files
some fixes
1 parent 15aeb09 commit fe93a1f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hichemtab-tech/langify-laravel",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"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.",
55
"keywords": [
66
"multilingual",

src/Console/Commands/GenerateLangs.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function handle(): void
9898
foreach ($result as $lang => $data) {
9999
foreach ($data as $key => $value) {
100100
$replacements = [
101-
'{{CONTENT}}' => var_export($value, true),
101+
'{{CONTENT}}' => $this->var_export_with_square_brackets(var_export($value, true)),
102102
];
103103
$template = File::get(__DIR__.'/stubs/langPlaceholder.stub');
104104
$generatedClass = str_replace(array_keys($replacements), array_values($replacements), $template);
@@ -110,4 +110,10 @@ public function handle(): void
110110
}
111111
$this->info("Done!");
112112
}
113+
114+
function var_export_with_square_brackets($expression): array|string|null
115+
{
116+
$expression = preg_replace('/^array\s\(/', '[', $expression);
117+
return preg_replace('/\)$/', ']', $expression);
118+
}
113119
}

0 commit comments

Comments
 (0)