Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selective local check #4156

Open
wants to merge 1 commit into
base: 9.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Drupal/Commands/core/LocaleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\Core\State\StateInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drush\Commands\DrushCommands;
use Drush\Utils\StringUtils;

class LocaleCommands extends DrushCommands
{
Expand Down Expand Up @@ -66,17 +67,26 @@ public function __construct(LanguageManagerInterface $languageManager, ConfigFac
*
* @command locale:check
* @aliases locale-check
* @option projects A comma-separated list of projects to update. If omitted, all projects will be updated.
* @validate-module-enabled locale
*/
public function check()
public function check($options = ['projects' => ''])
{
$this->getModuleHandler()->loadInclude('locale', 'inc', 'locale.compare');

$projects = [];
if ($passed_projects = $options['projects']) {
$projects = StringUtils::csvToArray($passed_projects);
}

// Remove duplicate projects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fond of documentation that only describes what the code does. If it does not add value, it is an additional maintenance burden.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basarkar, thanks for contributing this code. I agree that it is an added value to the existing command.

It also needs a test.

Copy link
Contributor

@Sutharsan Sutharsan Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@basarkar, Please explain the purpose of an selective locale:check command if the local:update command is not selective.

$projects = array_unique($projects);

// Check translation status of all translatable project in all languages.
// First we clear the cached list of projects. Although not strictly
// necessary, this is helpful in case the project list is out of sync.
locale_translation_flush_projects();
locale_translation_check_projects();
locale_translation_check_projects($projects);

// Execute a batch if required. A batch is only used when remote files
// are checked.
Expand Down