Skip to content

Commit

Permalink
Merge pull request #263 from Laravel-Lang/14.x
Browse files Browse the repository at this point in the history
Fixed writing console messages
  • Loading branch information
Andrey Helldar authored Jun 30, 2022
2 parents 6071044 + 39f4f63 commit b4b5612
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/Concerns/Output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace LaravelLang\Publisher\Concerns;

trait Output
{
protected function info(string $message, string $style = 'fg=green'): void
{
$this->line($message, $style);
}

protected function line(string $message, ?string $style = null): void
{
$line = ! empty($style) ? sprintf('<%s>%s</>', $style, $message) : $message;

$this->output->writeln($line);
}
}
8 changes: 5 additions & 3 deletions src/Processors/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use DragonCode\Support\Facades\Helpers\Arr;
use Illuminate\Console\OutputStyle;
use LaravelLang\Publisher\Concerns\Has;
use LaravelLang\Publisher\Concerns\Output;
use LaravelLang\Publisher\Concerns\Path;
use LaravelLang\Publisher\Helpers\Config;
use LaravelLang\Publisher\Plugins\Plugin;
Expand All @@ -30,6 +31,7 @@
abstract class Processor
{
use Has;
use Output;
use Path;

protected bool $reset = false;
Expand All @@ -52,12 +54,12 @@ public function prepare(): self

public function collect(): self
{
$this->output->info('Collecting localizations...');
$this->info('Collecting localizations...');

foreach ($this->plugins() as $directory => $plugins) {
/** @var Plugin $plugin */
foreach ($plugins as $plugin) {
$this->output->info(get_class($plugin) . '...');
$this->line(get_class($plugin) . '...');

$this->collectKeys($directory, $plugin->files());
}
Expand All @@ -70,7 +72,7 @@ public function collect(): self

public function store(): void
{
$this->output->info('Storing changes...');
$this->info('Storing changes...');

foreach ($this->translation->toArray() as $filename => $values) {
$path = $this->config->langPath($filename);
Expand Down

0 comments on commit b4b5612

Please sign in to comment.