diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationCacheTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationCacheTest.php new file mode 100644 index 0000000..3d4407c --- /dev/null +++ b/core/modules/config_translation/src/Tests/ConfigTranslationCacheTest.php @@ -0,0 +1,183 @@ +getPermissionName(), + $full_html_format->getPermissionName(), + $filter_test_format->getPermissionName(), + 'access site-wide contact form', + 'access contextual links', + 'administer account settings', + 'administer themes', + 'bypass node access', + 'administer content types', + 'translate interface', + 'administer entity_test fields', + ] + ); + // Create and login user. + $this->translatorUser = $this->drupalCreateUser($translator_permissions); + $this->adminUser = $this->drupalCreateUser($admin_permissions); + + // Add languages. + foreach ($this->langcodes as $langcode) { + ConfigurableLanguage::createFromLangcode($langcode)->save(); + } + $this->drupalPlaceBlock('local_tasks_block'); + $this->drupalPlaceBlock('page_title_block'); + } + + /** + * Tests the translation of field and field storage configuration. + */ + public function testFieldConfigTranslation() { + // Add a test field which has a translatable field setting and a + // translatable field storage setting. + $field_name = strtolower($this->randomMachineName()); + $field_storage = FieldStorageConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'type' => 'test_field', + ]); + + $translatable_storage_setting = $this->randomString(); + $field_storage->setSetting('translatable_storage_setting', $translatable_storage_setting); + $field_storage->save(); + + $bundle = strtolower($this->randomMachineName()); + entity_test_create_bundle($bundle); + $field = FieldConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'bundle' => $bundle, + ]); + + $translatable_field_setting = $this->randomString(); + $field->setSetting('translatable_field_setting', $translatable_field_setting); + $field->save(); + + $this->drupalLogin($this->translatorUser); + + $this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate"); + $this->clickLink('Add'); + + $this->assertText('Translatable field setting'); + $this->assertEscaped($translatable_field_setting); + $this->assertText('Translatable storage setting'); + $this->assertEscaped($translatable_storage_setting); + + // Add translation for label. + $field_label_fr = $this->randomString(); + $edit = array( + "translation[config_names][field.field.entity_test.$bundle.$field_name][label]" => $field_label_fr, + ); + $this->drupalPostForm(NULL, $edit, 'Save translation'); + $this->drupalLogout(); + + // Check if the translated label appear. + $this->drupalLogin($this->adminUser); + $this->drupalGet("/fr/entity_test/structure/$bundle/fields"); + $this->assertEscaped($field_label_fr); + + // Clear cache on French version and check for translated label. + $this->drupalPostForm('/fr/admin/config/development/performance', array(), 'Clear all caches'); + $this->drupalGet("/fr/entity_test/structure/$bundle/fields"); + // Check if the translation still there. + $this->assertEscaped($field_label_fr); + + // Clear cache on default version and check for translated label. + $this->drupalPostForm('/admin/config/development/performance', array(), 'Clear all caches'); + $this->drupalGet("/fr/entity_test/structure/$bundle/fields"); + // Check if the translation still there. + $this->assertEscaped($field_label_fr); + } + +} diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 966cc1a..2087805 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -129,7 +129,7 @@ protected function defineOptions() { protected function getRoute($view_id, $display_id) { $defaults = array( '_controller' => 'Drupal\views\Routing\ViewPageController::handle', - '_title' => $this->view->getTitle(), + '_title_callback' => get_class($this) . '::getTitle', 'view_id' => $view_id, 'display_id' => $display_id, '_view_display_show_admin_links' => $this->getOption('show_admin_links'), @@ -533,4 +533,18 @@ public function remove() { } } + /** + * Title callback. + * + * Using callback as direct call to getTitle(() in route definition causing + * issues with configuration translation system. + * + * @see https://www.drupal.org/node/2650434 + * + * @return false|string + */ + public function getTitle() { + return $this->view->getTitle(); + } + }