-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philippe Damen
committed
Feb 2, 2024
1 parent
e223c19
commit 32d7b46
Showing
6 changed files
with
101 additions
and
127 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace NextApps\PoeditorSync\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Collection; | ||
use NextApps\PoeditorSync\Poeditor\Poeditor; | ||
use NextApps\PoeditorSync\Translations\TranslationManager; | ||
|
||
class StatusCommand extends Command | ||
{ | ||
protected $signature = 'poeditor:status'; | ||
|
||
protected $description = 'Check if local translations match the ones on POEditor'; | ||
|
||
public function handle() : int | ||
{ | ||
$isOutdated = $this->getLocales()->map(function ($locale, $key) { | ||
$poeditorTranslations = app(Poeditor::class)->download(is_string($key) ? $key : $locale); | ||
|
||
return collect($locale)->map(function ($internalLocale) use ($poeditorTranslations) { | ||
$localTranslations = app(TranslationManager::class)->getTranslations($internalLocale); | ||
|
||
if ($poeditorTranslations === $localTranslations) { | ||
return true; | ||
} | ||
|
||
$this->error("The translations for '{$internalLocale}' do not match the ones on POEditor."); | ||
|
||
return false; | ||
}); | ||
})->flatten()->contains(false); | ||
|
||
if ($isOutdated) { | ||
return Command::FAILURE; | ||
} | ||
|
||
$this->info('All translations match the ones on POEditor!'); | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
||
protected function getLocales() : Collection | ||
{ | ||
return collect(config('poeditor-sync.locales')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters