Skip to content

Commit

Permalink
Fixed generating translations on windows (#20)
Browse files Browse the repository at this point in the history
* Fixed generating translations on windows ( used 'PHP_EOL' instead of '\n' )

* Replaced other occurrences of '\n' with 'PHP_EOL'
  • Loading branch information
timoransky authored and dejwCake committed Aug 9, 2018
1 parent ff73a02 commit 78f7194
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Generate/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function handle()
resource_path('views/admin/layout/sidebar.blade.php'),
'|url\(\'admin\/'.$this->resource.'\'\)|',
"{{-- Do not delete me :) I'm used for auto-generation menu items --}}",
"<li class=\"nav-item\"><a class=\"nav-link\" href=\"{{ url('admin/".$this->resource."') }}\"><i class=\"".$icon."\"></i> <span class=\"nav-link-text\">{{ trans('admin.".$this->modelLangFormat.".title') }}</span></a></li>\n {{-- Do not delete me :) I'm used for auto-generation menu items --}}"
"<li class=\"nav-item\"><a class=\"nav-link\" href=\"{{ url('admin/".$this->resource."') }}\"><i class=\"".$icon."\"></i> <span class=\"nav-link-text\">{{ trans('admin.".$this->modelLangFormat.".title') }}</span></a></li>".PHP_EOL." {{-- Do not delete me :) I'm used for auto-generation menu items --}}"
)) {
$this->info('Updating sidebar');
}
Expand Down Expand Up @@ -122,4 +122,4 @@ protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Http\Controllers\Admin';
}
}
}
6 changes: 3 additions & 3 deletions src/Generate/FileAppender.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function getArguments() {
* @param string $defaultContent content that will be used to populated with newly created file (in case it does not already exists)
* @return bool
*/
protected function appendIfNotAlreadyAppended($path, $content, $defaultContent = "<?php\n\n")
protected function appendIfNotAlreadyAppended($path, $content, $defaultContent = "<?php".PHP_EOL.PHP_EOL)
{
if (!$this->files->exists($path)) {
$this->makeDirectory($path);
Expand All @@ -74,7 +74,7 @@ protected function appendIfNotAlreadyAppended($path, $content, $defaultContent =
* @param string $defaultContent content that will be used to populated with newly created file (in case it does not already exists)
* @return bool
*/
protected function replaceIfNotPresent($path, $search, $replace, $defaultContent = "<?php\n\n")
protected function replaceIfNotPresent($path, $search, $replace, $defaultContent = "<?php".PHP_EOL.PHP_EOL)
{
if (!$this->files->exists($path)) {
$this->makeDirectory($path);
Expand Down Expand Up @@ -104,4 +104,4 @@ protected function execute(InputInterface $input, OutputInterface $output)

return $output;
}
}
}
4 changes: 2 additions & 2 deletions src/Generate/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle()

// TODO name-spaced model names should be probably inserted as a sub-array in a translation file..

if ($this->replaceIfNotPresent(resource_path('lang/'.$locale.'/admin.php'), "// Do not delete me :) I'm used for auto-generation\n",$this->buildClass()."\n", "<?php\n\nreturn [\n // Do not delete me :) I'm used for auto-generation\n];")){
if ($this->replaceIfNotPresent(resource_path('lang/'.$locale.'/admin.php'), "// Do not delete me :) I'm used for auto-generation".PHP_EOL,$this->buildClass().PHP_EOL, "<?php".PHP_EOL.PHP_EOL."return [".PHP_EOL." // Do not delete me :) I'm used for auto-generation".PHP_EOL."];")){
$this->info('Appending translations finished');
}
}
Expand All @@ -78,4 +78,4 @@ protected function getOptions() {
];
}

}
}
4 changes: 2 additions & 2 deletions src/Generate/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function handle()
$this->view = 'templates.'.$template.'.routes';
}

if ($this->appendIfNotAlreadyAppended(base_path('routes/web.php'), "\n\n".$this->buildClass())){
if ($this->appendIfNotAlreadyAppended(base_path('routes/web.php'), PHP_EOL.PHP_EOL.$this->buildClass())){
$this->info('Appending routes finished');
}
}
Expand All @@ -63,4 +63,4 @@ protected function getOptions() {
];
}

}
}
6 changes: 3 additions & 3 deletions src/Generate/ViewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public function handle()
$indexJsPath = resource_path('assets/admin/js/'.$this->modelJSName.'/index.js');
$bootstrapJsPath = resource_path('assets/admin/js/index.js');

if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Form';\n")){
if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Form';".PHP_EOL)){
$this->info('Appending Form to '.$indexJsPath.' finished');
};
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './".$this->modelJSName."';\n")){
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './".$this->modelJSName."';".PHP_EOL)){
$this->info('Appending Form to '.$bootstrapJsPath.' finished');
};
}
Expand Down Expand Up @@ -227,4 +227,4 @@ protected function getOptions() {
];
}

}
}
6 changes: 3 additions & 3 deletions src/Generate/ViewFullForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public function handle()
$this->makeDirectory($indexJsPath);
}

if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Form';\n")){
if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Form';".PHP_EOL)){
$this->info('Appending Form to '.$indexJsPath.' finished');
};
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './". $this->formJsRelativePath ."';\n")){
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './". $this->formJsRelativePath ."';".PHP_EOL)){
$this->info('Appending '.$this->formJsRelativePath.'/index.js to '.$bootstrapJsPath.' finished');
};

Expand Down Expand Up @@ -180,4 +180,4 @@ protected function getOptions() {
];
}

}
}
6 changes: 3 additions & 3 deletions src/Generate/ViewIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public function handle()
}


if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Listing';\n")){
if ($this->appendIfNotAlreadyAppended($indexJsPath, "import './Listing';".PHP_EOL)){
$this->info('Appending Listing to '.$indexJsPath.' finished');
}
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './". $this->modelJSName ."';\n")){
if ($this->appendIfNotAlreadyAppended($bootstrapJsPath, "import './". $this->modelJSName ."';".PHP_EOL)){
$this->info('Appending '.$this->modelJSName.'/index.js to '.$bootstrapJsPath.' finished');
};
}
Expand Down Expand Up @@ -149,4 +149,4 @@ protected function getOptions() {
];
}

}
}

0 comments on commit 78f7194

Please sign in to comment.