Skip to content

Commit

Permalink
Added ignored translation files for cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeybob committed Apr 10, 2018
1 parent ec6cc7d commit 0977976
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Options:
force | Should the update be done | false
dump-messages | Should the messages be dumped in the console | false
no-backup | Should backup not be done | false
clean | Should clean not found messages | false
clean | Should clean not found messages. But we will ignore next files: 'validation', 'auth', 'passwords', 'pagination' | false
prefix | Override the default prefix. | __,@lang,trans_choice,@choice,__ab,trans_choice_ab

### Diff Command:
Expand Down
2 changes: 1 addition & 1 deletion src/Console/TranslationDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class TranslationDiffCommand extends Command
{
private $messages = [];
private $newMessages = [];

/**
* The name and signature of the console command.
Expand Down
9 changes: 6 additions & 3 deletions src/Services/TranslatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ public function __construct(string $locale, string $path, string $prefixes, stri
public function clean()
{
foreach ($this->resources as $resource) {
foreach ($resource->getTranslations() as $key => $value) {
if (false === $this->hasMessage($key)) {
$resource->deleteMessage($this->cleanMessage($key));

if (false === in_array($resource->getFileBaseName(), ['validation', 'auth', 'passwords', 'pagination'])) {
foreach ($resource->getTranslations() as $key => $value) {
if (false === $this->hasMessage($key)) {
$resource->deleteMessage($this->cleanMessage($key));
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function getMessages() : array
/**
*
* @param string $key
* @return string
* @return mixed
*/
public function getMessage(string $key) : string
public function getMessage(string $key)
{
foreach ($this->messages as $message) {
if ($key === $message['value']) {
Expand Down

0 comments on commit 0977976

Please sign in to comment.