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 locale-check #3601

Open
wants to merge 4 commits into
base: 8.x
Choose a base branch
from
Open
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion commands/core/locale.d8.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ function locale_drush_command() {
$items['locale-check'] = [
'description' => 'Checks for available translation updates.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'options' => [
'projects' => 'A comma separated and no space list of interface translation projects language to update. If omitted, all the installed projects will be updated.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't make the user think, fix this in code by proper treatment of the input.

Suggested change
'projects' => 'A comma separated and no space list of interface translation projects language to update. If omitted, all the installed projects will be updated.',
'projects' => 'A comma delimited list of projects to update. If omitted, all projects will be updated.',

],
'examples' => [
'drush locale-check' => 'Language update for all installed interface translation projects.',
Copy link
Contributor

Choose a reason for hiding this comment

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

This command does not update, it only checks.

Suggested change
'drush locale-check' => 'Language update for all installed interface translation projects.',
'drush locale-check' => 'Checks all projects.',

I removed the word "installed" as this is not relevant. Not installed projects are never checked.
I removed "interface translation" as this is the context of the command, and I don't see the need to repeat that here.

'drush locale-check --projects=custom_module,paragraphs' => 'Language update for custom_module and paragraphs.',
Copy link
Contributor

Choose a reason for hiding this comment

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

As above.

Suggested change
'drush locale-check --projects=custom_module,paragraphs' => 'Language update for custom_module and paragraphs.',
'drush locale-check --projects=custom_module,paragraphs' => 'Checks the custom_module and paragraphs projects.',

],
];
$items['locale-update'] = [
'description' => 'Updates the available translations.',
Expand All @@ -45,13 +52,22 @@ function locale_drush_command() {
* in Drupal core.
*/
function drush_locale_check() {
// Prepare the projects array.
$projects = drush_get_option('projects', NULL);
if (!empty($projects)) {
$projects = array_filter(explode(',', $projects));
Copy link
Contributor

Choose a reason for hiding this comment

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

As suggested by Moshe

Suggested change
$projects = array_filter(explode(',', $projects));
$projects = _convert_csv_to_array($projects);

}
else {
$projects = [];
}

\Drupal::moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');

// 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