diff -u b/modules/video_embed_media/src/Plugin/MediaEntity/Type/VideoEmbedField.php b/modules/video_embed_media/src/Plugin/MediaEntity/Type/VideoEmbedField.php --- b/modules/video_embed_media/src/Plugin/MediaEntity/Type/VideoEmbedField.php +++ b/modules/video_embed_media/src/Plugin/MediaEntity/Type/VideoEmbedField.php @@ -12,6 +12,7 @@ use Drupal\video_embed_field\ProviderManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\Config; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Provides media type plugin for video embed field. @@ -24,6 +25,8 @@ */ class VideoEmbedField extends MediaTypeBase { + use StringTranslationTrait; + /** * The name of the field on the media entity. */ reverted: --- b/modules/video_embed_wysiwyg/video_embed_wysiwyg.module +++ a/modules/video_embed_wysiwyg/video_embed_wysiwyg.module @@ -42,7 +42,7 @@ } // The button and filter can either both be enabled or disabled. if ($filter_enabled !== $button_enabled) { + $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], t('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.')); - $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], $this->t('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.')); } } @@ -61,14 +61,14 @@ if (!empty($form_state->getValue(['filters', 'filter_url', 'status']))) { $filter_weight = $form_state->getValue(['filters', 'filter_url', 'weight']); if ($wysiwyg_weight > $filter_weight) { + $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], t('The "Video Embed WYSIWYG" filter must run before the "Convert URLs into links" filter to function correctly.')); - $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], $this->t('The "Video Embed WYSIWYG" filter must run before the "Convert URLs into links" filter to function correctly.')); } } // Check the WYSIWYG filter runs after the HTML tag filter. if (!empty($form_state->getValue(['filters', 'filter_html', 'status']))) { $html_filter_weight = $form_state->getValue(['filters', 'filter_html', 'weight']); if ($wysiwyg_weight < $html_filter_weight) { + $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], t('The "Video Embed WYSIWYG" filter must run after the "Limit allowed HTML tags" filter to function correctly.')); - $form_state->setError($form['filters']['status']['video_embed_wysiwyg'], $this->t('The "Video Embed WYSIWYG" filter must run after the "Limit allowed HTML tags" filter to function correctly.')); } } } only in patch2: unchanged: --- a/modules/video_embed_media/tests/src/Functional/BundleTest.php +++ b/modules/video_embed_media/tests/src/Functional/BundleTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_media\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test the video_embed_field media integration. @@ -12,6 +13,7 @@ use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; */ class BundleTest extends BrowserTestBase { + use StringTranslationTrait; use AdminUserTrait; /** @@ -40,7 +42,7 @@ class BundleTest extends BrowserTestBase { 'label' => 'Video Bundle', 'id' => 'video_bundle', 'type' => 'video_embed_field', - ], t('Save media bundle')); + ], $this->t('Save media bundle')); $this->assertSession()->pageTextContains('The media bundle Video Bundle has been added.'); // Ensure the video field is added to the media entity. @@ -64,14 +66,14 @@ class BundleTest extends BrowserTestBase { 'label' => 'New Video Field', 'field_name' => 'new_video_field', ], 'Save and continue'); - $this->submitForm([], t('Save field settings')); - $this->submitForm([], t('Save settings')); + $this->submitForm([], $this->t('Save field settings')); + $this->submitForm([], $this->t('Save settings')); // Update video source field. $this->drupalGet('admin/structure/media/manage/video_bundle'); $this->submitForm([ 'type_configuration[video_embed_field][source_field]' => 'field_new_video_field', - ], t('Save media bundle')); + ], $this->t('Save media bundle')); // Create a video, populating both video URL fields. $this->drupalGet('media/add/video_bundle'); @@ -79,7 +81,7 @@ class BundleTest extends BrowserTestBase { 'name[0][value]' => 'Another Video!', 'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', 'field_new_video_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', - ], t('Save')); + ], $this->t('Save')); // We should see the newly configured video thumbnail, but not the original. $this->assertContains('video_thumbnails/gnERPdAiuSo.jpg', $this->getSession()->getPage()->getHtml()); only in patch2: unchanged: --- a/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php +++ b/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_media\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test the upgrade path from media_entity_embedded_video. @@ -12,6 +13,7 @@ use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; */ class UpgradePathTest extends BrowserTestBase { + use StringTranslationTrait; use AdminUserTrait; /** @@ -48,16 +50,16 @@ class UpgradePathTest extends BrowserTestBase { 'new_storage_type' => 'string', 'label' => 'Video Text Field', 'field_name' => 'video_text_field', - ], t('Save and continue')); - $this->submitForm([], t('Save field settings')); - $this->submitForm([], t('Save settings')); + ], $this->t('Save and continue')); + $this->submitForm([], $this->t('Save field settings')); + $this->submitForm([], $this->t('Save settings')); $this->drupalGet('admin/structure/media/manage/embeddable_bundle'); - $this->submitForm(['type_configuration[embeddable_video][source_field]' => 'field_video_text_field'], t('Save media bundle')); + $this->submitForm(['type_configuration[embeddable_video][source_field]' => 'field_video_text_field'], $this->t('Save media bundle')); $this->drupalGet('media/add/embeddable_bundle'); $this->submitForm([ 'field_video_text_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', 'name[0][value]' => 'Test Media Entity', - ], t('Save')); + ], $this->t('Save')); // Install video_embed_field. $this->container->get('module_installer')->install(['video_embed_media'], TRUE); @@ -68,7 +70,7 @@ class UpgradePathTest extends BrowserTestBase { $this->drupalGet('admin/modules/uninstall'); $this->submitForm([ 'uninstall[media_entity_embeddable_video]' => TRUE, - ], t('Uninstall')); + ], $this->t('Uninstall')); $this->submitForm([], 'Uninstall'); $this->assertUpgradeComplete(); only in patch2: unchanged: --- a/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php +++ b/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_wysiwyg\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test the format configuration form. @@ -12,6 +13,7 @@ use Drupal\Tests\video_embed_field\Functional\AdminUserTrait; */ class TextFormatConfigurationTest extends BrowserTestBase { + use StringTranslationTrait; use AdminUserTrait; /** @@ -46,7 +48,7 @@ class TextFormatConfigurationTest extends BrowserTestBase { // Setup the filter to have an editor. $this->getSession()->getPage()->find('css', '[name="editor[editor]"]')->setValue('ckeditor'); $this->getSession()->getPage()->find('css', 'input[name="editor_configure"]')->click(); - $this->submitForm([], t('Save configuration')); + $this->submitForm([], $this->t('Save configuration')); } /** @@ -58,21 +60,21 @@ class TextFormatConfigurationTest extends BrowserTestBase { $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[]', - ], t('Save configuration')); + ], $this->t('Save configuration')); $this->assertSession()->pageTextContains('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.'); $this->drupalGet($this->formatUrl); $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => FALSE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', - ], t('Save configuration')); + ], $this->t('Save configuration')); $this->assertSession()->pageTextContains('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.'); $this->drupalGet($this->formatUrl); $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', - ], t('Save configuration')); + ], $this->t('Save configuration')); $this->assertSession()->pageTextContains('The text format Plain text has been updated.'); } @@ -146,7 +148,7 @@ class TextFormatConfigurationTest extends BrowserTestBase { 'editor[settings][plugins][video_embed][defaults][children][height]' => '456', 'editor[settings][plugins][video_embed][defaults][children][responsive]' => FALSE, 'editor[settings][plugins][video_embed][defaults][children][autoplay]' => FALSE, - ], t('Save configuration')); + ], $this->t('Save configuration')); // Ensure the configured defaults show up on the modal window. $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); only in patch2: unchanged: --- a/modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php +++ b/modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_wysiwyg\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; use Drupal\simpletest\ContentTypeCreationTrait; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test the dialog form. @@ -12,6 +13,7 @@ use Drupal\simpletest\ContentTypeCreationTrait; */ class EmbedDialogTest extends JavascriptTestBase { + use StringTranslationTrait; use ContentTypeCreationTrait; /** @@ -62,7 +64,7 @@ class EmbedDialogTest extends JavascriptTestBase { $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed","Source"]}]]', - ], t('Save configuration')); + ], $this->t('Save configuration')); // Visit the modal again. $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); only in patch2: unchanged: --- a/src/Plugin/Field/FieldWidget/VideoTextfield.php +++ b/src/Plugin/Field/FieldWidget/VideoTextfield.php @@ -5,6 +5,7 @@ namespace Drupal\video_embed_field\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * A widget to input video URLs. @@ -64,7 +65,7 @@ class VideoTextfield extends WidgetBase { * The provider error message. */ public static function getProviderErrorMessage() { - return t('Could not find a video provider to handle the given URL.'); + return StringTranslationTrait::t('Could not find a video provider to handle the given URL.'); } } only in patch2: unchanged: --- a/tests/src/Functional/FieldConfigurationTest.php +++ b/tests/src/Functional/FieldConfigurationTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\video_embed_field\Functional; use Drupal\Tests\BrowserTestBase; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Integration test for the field configuration form. @@ -11,6 +12,7 @@ use Drupal\Tests\BrowserTestBase; */ class FieldConfigurationTest extends BrowserTestBase { + use StringTranslationTrait; use EntityDisplaySetupTrait; use AdminUserTrait; @@ -35,8 +37,8 @@ class FieldConfigurationTest extends BrowserTestBase { 'new_storage_type' => 'video_embed_field', 'label' => 'Video Embed', 'field_name' => 'video_embed', - ], t('Save and continue')); - $this->submitForm([], t('Save field settings')); + ], $this->t('Save and continue')); + $this->submitForm([], $this->t('Save field settings')); $this->submitForm([ 'label' => 'Video Embed', 'description' => 'Some help.', @@ -45,11 +47,11 @@ class FieldConfigurationTest extends BrowserTestBase { 'settings[allowed_providers][vimeo]' => 'vimeo', 'settings[allowed_providers][youtube]' => 'youtube', 'settings[allowed_providers][youtube_playlist]' => 'youtube_playlist', - ], t('Save settings')); + ], $this->t('Save settings')); $this->assertSession()->pageTextContains('Could not find a video provider to handle the given URL.'); $this->submitForm([ 'default_value_input[field_video_embed][0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', - ], t('Save settings')); + ], $this->t('Save settings')); $this->assertSession()->pageTextContains('Saved Video Embed configuration.'); } only in patch2: unchanged: --- a/tests/src/Functional/FormatterConfigurationTest.php +++ b/tests/src/Functional/FormatterConfigurationTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_field\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\video_embed_field\Plugin\Field\FieldFormatter\Thumbnail; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Tests the field formatter configuration forms. @@ -12,6 +13,7 @@ use Drupal\video_embed_field\Plugin\Field\FieldFormatter\Thumbnail; */ class FormatterConfigurationTest extends BrowserTestBase { + use StringTranslationTrait; use AdminUserTrait; use EntityDisplaySetupTrait; @@ -99,8 +101,8 @@ class FormatterConfigurationTest extends BrowserTestBase { $this->find('input[name="refresh_rows"]')->setValue($this->fieldName); $this->submitForm([ 'fields[' . $this->fieldName . '][type]' => $formatter, - ], t('Refresh')); - $this->submitForm([], t('Save')); + ], $this->t('Refresh')); + $this->submitForm([], $this->t('Save')); } /** @@ -117,7 +119,7 @@ class FormatterConfigurationTest extends BrowserTestBase { $this->drupalGet($this->manageDisplay); $this->find('input[name="' . $this->fieldName . '_settings_edit"]')->click(); $this->submitForm($edit, $this->fieldName . '_plugin_settings_update'); - $this->submitForm([], t('Save')); + $this->submitForm([], $this->t('Save')); } /** only in patch2: unchanged: --- a/tests/src/Functional/WidgetTest.php +++ b/tests/src/Functional/WidgetTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\video_embed_field\Functional; use Drupal\Core\Url; use Drupal\Tests\BrowserTestBase; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test the video embed field widget. @@ -12,6 +13,7 @@ use Drupal\Tests\BrowserTestBase; */ class WidgetTest extends BrowserTestBase { + use StringTranslationTrait; use EntityDisplaySetupTrait; use AdminUserTrait; @@ -39,14 +41,14 @@ class WidgetTest extends BrowserTestBase { $this->submitForm([ 'title[0][value]' => $node_title, $this->fieldName . '[0][value]' => 'Some useless value.', - ], t('Save and publish')); + ], $this->t('Save and publish')); $this->assertSession()->pageTextContains('Could not find a video provider to handle the given URL.'); // Test a valid input. $valid_input = 'https://vimeo.com/80896303'; $this->submitForm([ $this->fieldName . '[0][value]' => $valid_input, - ], t('Save and publish')); + ], $this->t('Save and publish')); $this->assertSession()->pageTextContains(sprintf('%s %s has been created.', $this->contentTypeName, $node_title)); // Load the saved node and assert the valid value was saved into the field.