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

EWPP-3578: Fix the message of the import-local-translations drush command. #157

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ services:
- COMPOSERVER=--2
- DOCUMENT_ROOT=/test/oe_multilingual
mysql:
image: registry.fpfis.eu/fpfis/sql:percona-5.7
image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/percona:5.7
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
selenium:
image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-3.141.59-oxygen
image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/selenium/standalone-chrome:4.1.3-20220405
shm_size: 2g
environment:
- DISPLAY=:99
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(ConfigFactoryInterface $config, AliasManager $aliasM
/**
* {@inheritdoc}
*/
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
// Ensure front-page path has the configured alias of the front-page
// in order to avoid links pointing to "/_[language_suffix]".
if (in_array($path, ['/<front>', '/'])) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual_front_page\Unit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Install, update and uninstall functions for the module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\language_selection_page\Plugin\LanguageNegotiation\LanguageNegotiationLanguageSelectionPage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Contains hooks to manipulate language links for selection page.
*/

declare(strict_types = 1);
declare(strict_types=1);

/**
* Implements hook_page_preprocess().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Post update hooks.
*/

declare(strict_types = 1);
declare(strict_types=1);

/**
* Updates the language selection page to not include the private files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Install, update and uninstall functions for the module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* The OpenEuropa Multilingual URL suffix module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual_url_suffix\Event;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual_url_suffix\Form;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual_url_suffix\Plugin\LanguageNegotiation;

Expand Down Expand Up @@ -100,7 +100,7 @@ public static function create(ContainerInterface $container, array $configuratio
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function getLangcode(Request $request = NULL) {
public function getLangcode(?Request $request = NULL) {
$langcode = NULL;

$url_suffixes = $this->getUrlSuffixes($request->getPathInfo());
Expand Down Expand Up @@ -170,7 +170,7 @@ public function processInbound($path, Request $request) {
/**
* {@inheritdoc}
*/
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
$languages = array_flip(array_keys($this->languageManager->getLanguages()));
// Language can be passed as an option, or we go for current URL language.
if (!isset($options['language'])) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual_url_suffix_test\EventSubscriber;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual_url_suffix\Functional;

Expand Down Expand Up @@ -73,7 +73,7 @@ protected function setUp(): void {
'language_content[enabled][language-url]' => 0,
];
$this->drupalGet('admin/config/regional/language/detection');
$this->submitForm($edit, t('Save settings'));
$this->submitForm($edit, 'Save settings');
}

/**
Expand All @@ -88,14 +88,14 @@ public function testInbound(): void {
'suffix[en]' => 'eng',
];
$this->drupalGet('/admin/config/regional/language/detection/url-suffix_en', ['external' => FALSE]);
$this->submitForm($edit, $this->t('Save configuration'));
$this->submitForm($edit, 'Save configuration');

$nodeValues = [
'title[0][value]' => 'Test',
'path[0][alias]' => '/test_eng',
];
$this->drupalGet('/node/add/article_eng', ['external' => FALSE]);
$this->submitForm($nodeValues, $this->t('Save'));
$this->submitForm($nodeValues, 'Save');
$this->assertSession()->statusCodeEquals(200);

$this->drupalGet('/test_eng_eng', ['external' => FALSE]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual_url_suffix\Kernel;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual_url_suffix\Unit;

Expand Down Expand Up @@ -96,7 +96,7 @@ protected function setUp(): void {
*
* @dataProvider providerTestPathSuffix
*/
public function testPathSuffix(string $suffix, array $suffixes, string $expected_langcode = NULL): void {
public function testPathSuffix(string $suffix, array $suffixes, ?string $expected_langcode = NULL): void {
$language_code = (in_array($expected_langcode, ['en', 'de'])) ? $expected_langcode : 'en';
$this->languageManager->expects($this->any())
->method('getCurrentLanguage')
Expand Down
2 changes: 1 addition & 1 deletion oe_multilingual.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Install, update and uninstall functions for the oe_multilingual module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected;
Expand Down
2 changes: 1 addition & 1 deletion oe_multilingual.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Multilingual module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Component\Gettext\PoStreamReader;
use Drupal\Core\Entity\EntityInterface;
Expand Down
2 changes: 1 addition & 1 deletion oe_multilingual.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Post update functions for OpenEuropa Multilingual module.
*/

declare(strict_types = 1);
declare(strict_types=1);

/**
* Invalidate service containers.
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MultilingualCommands.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual\Commands;

Expand Down
4 changes: 2 additions & 2 deletions src/ContentLanguageSwitcherProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down Expand Up @@ -56,7 +56,7 @@ class ContentLanguageSwitcherProvider {
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(LanguageManagerInterface $language_manager, PathMatcherInterface $path_matcher, MultilingualHelperInterface $multilingual_helper, RouteMatchInterface $route_match = NULL) {
public function __construct(LanguageManagerInterface $language_manager, PathMatcherInterface $path_matcher, MultilingualHelperInterface $multilingual_helper, ?RouteMatchInterface $route_match = NULL) {
$this->languageManager = $language_manager;
$this->pathMatcher = $path_matcher;
$this->multilingualHelper = $multilingual_helper;
Expand Down
2 changes: 1 addition & 1 deletion src/LanguageNegotiationSetter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down
2 changes: 1 addition & 1 deletion src/LanguageNegotiationSetterInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down
9 changes: 6 additions & 3 deletions src/LocalTranslationsBatcher.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down Expand Up @@ -190,6 +190,7 @@ public function importProjectPoFiles($extension, $langcodes, &$context): void {
$this->fileSystem->dirname($extension['info']['interface translation server pattern']),
'/.*-(' . implode('|', $langcodes) . ')\.po/'
);
$message = '';
foreach ($files as $file) {
preg_match('/(' . implode('|', $langcodes) . ')$/', $file->name, $matches);
$file->langcode = $matches[0];
Expand All @@ -198,12 +199,14 @@ public function importProjectPoFiles($extension, $langcodes, &$context): void {
'not_customized' => TRUE,
],
]);

$context['message'] = $this->t('Imported translation for %project (%langcode).', [
// Drush won't print the message for each file of the same extension, so
// build a single message per extension to be printed at the end.
$message = $message . $this->t("Imported translation for %project (%langcode).\n", [
'%project' => $extension['name'],
'%langcode' => $file->langcode,
]);
}
$context['message'] = $message;
}

}
4 changes: 2 additions & 2 deletions src/MultilingualHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down Expand Up @@ -57,7 +57,7 @@ class MultilingualHelper implements MultilingualHelperInterface {
* @param \Drupal\Core\Entity\EntityTypeManagerInterface|null $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityRepositoryInterface $entity_repository, RouteMatchInterface $current_route_match, PathValidatorInterface $path_validator = NULL, EntityTypeManagerInterface $entity_type_manager = NULL) {
public function __construct(EntityRepositoryInterface $entity_repository, RouteMatchInterface $current_route_match, ?PathValidatorInterface $path_validator = NULL, ?EntityTypeManagerInterface $entity_type_manager = NULL) {
if (!$path_validator) {
$path_validator = \Drupal::service('path.validator');
}
Expand Down
2 changes: 1 addition & 1 deletion src/MultilingualHelperInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Block/ContentLanguageBlock.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual\Plugin\Block;

Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/LanguageNegotiation/LanguageNegotiationAdmin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_multilingual\Plugin\LanguageNegotiation;

Expand Down Expand Up @@ -28,7 +28,7 @@ class LanguageNegotiationAdmin extends LanguageNegotiationUserAdmin {
/**
* {@inheritdoc}
*/
public function getLangcode(Request $request = NULL): ?string {
public function getLangcode(?Request $request = NULL): ?string {
$langcode = NULL;

if ($this->currentUser->hasPermission('access administration pages') && $this->isAdminPath($request)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\translation_importer_test\Controller;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Behat/DrupalContext.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\Behat;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Behat/InterfaceTranslationContext.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\Behat;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Functional/ConfigurableLanguageTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\Functional;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/FunctionalJavascript/TranslationImporterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\FunctionalJavascript;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/InstallationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/LanguageNegotiationSetterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_multilingual\Kernel;

Expand Down