Skip to content

Commit 9ecb5eb

Browse files
committed
fix: localization file save fixes
1 parent bbe0009 commit 9ecb5eb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"mockery/mockery": "^1.4.4",
3636
"orchestra/testbench": "^7.5",
3737
"pestphp/pest": "^1.21",
38-
"pestphp/pest-plugin-laravel": "^1.2"
38+
"pestphp/pest-plugin-laravel": "^1.2",
39+
"symfony/var-exporter": "^6.0"
3940
},
4041
"autoload": {
4142
"psr-4": {

src/Commands/BaseCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use InfyOm\Generator\Utils\TableFieldsGenerator;
3333
use Symfony\Component\Console\Input\InputArgument;
3434
use Symfony\Component\Console\Input\InputOption;
35+
use Symfony\Component\VarExporter\VarExporter;
3536

3637
class BaseCommand extends Command
3738
{
@@ -246,14 +247,17 @@ private function saveLocaleFile()
246247
$locales['fields'][$field->name] = Str::title(str_replace('_', ' ', $field->name));
247248
}
248249

249-
$path = lang_path('en/models');
250+
$path = lang_path('en/models/');
250251

251-
$fileName = $this->config->modelNames->plural.'.php';
252+
$fileName = $this->config->modelNames->snakePlural.'.php';
252253

253254
if (file_exists($path.$fileName) && !$this->confirmOverwrite($fileName)) {
254255
return;
255256
}
256-
$content = "<?php\n\nreturn ".var_export($locales, true).';'.infy_nl();
257+
258+
$locales = VarExporter::export($locales);
259+
$end = ';'.infy_nl();
260+
$content = "<?php\n\nreturn ".$locales.$end;
257261
g_filesystem()->createFile($path.$fileName, $content);
258262
$this->comment("\nModel Locale File saved.");
259263
$this->info($fileName);

0 commit comments

Comments
 (0)