Issue #3037157 by phenaproxima, sudiptadas19, mohit_aghera, xjm, manuel.adan, Abhijith S, tanubansal, joachim, larowlan, tim.plunkett, catch: Vocabulary name not translated in page title of the taxonomy overview and reset forms
parent
c1179c9377
commit
cfca6ce40d
|
@ -34,8 +34,14 @@ class TaxonomyController extends ControllerBase {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* The vocabulary label as a render array.
|
* The vocabulary label as a render array.
|
||||||
|
*
|
||||||
|
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no
|
||||||
|
* replacement; route title callbacks are internal.
|
||||||
|
*
|
||||||
|
* @see https://www.drupal.org/project/drupal/issues/3037157
|
||||||
*/
|
*/
|
||||||
public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
|
public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
|
||||||
|
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement; route title callbacks are internal. See https://www.drupal.org/project/drupal/issues/3037157.', E_USER_DEPRECATED);
|
||||||
return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()];
|
return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,11 @@ class VocabularyRouteProvider extends AdminHtmlRouteProvider {
|
||||||
$route->setDefault('_title', 'Reset');
|
$route->setDefault('_title', 'Reset');
|
||||||
$route->setRequirement('_permission', $entity_type->getAdminPermission());
|
$route->setRequirement('_permission', $entity_type->getAdminPermission());
|
||||||
$route->setOption('_admin_route', TRUE);
|
$route->setOption('_admin_route', TRUE);
|
||||||
|
$route->setOption('parameters', [
|
||||||
|
'taxonomy_vocabulary' => [
|
||||||
|
'with_config_overrides' => TRUE,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
return $route;
|
return $route;
|
||||||
}
|
}
|
||||||
|
@ -66,10 +71,15 @@ class VocabularyRouteProvider extends AdminHtmlRouteProvider {
|
||||||
*/
|
*/
|
||||||
protected function getOverviewPageRoute(EntityTypeInterface $entity_type) {
|
protected function getOverviewPageRoute(EntityTypeInterface $entity_type) {
|
||||||
$route = new Route('/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview');
|
$route = new Route('/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview');
|
||||||
$route->setDefault('_title_callback', 'Drupal\taxonomy\Controller\TaxonomyController::vocabularyTitle');
|
$route->setDefault('_title_callback', '\Drupal\Core\Entity\Controller\EntityController::title');
|
||||||
$route->setDefault('_form', 'Drupal\taxonomy\Form\OverviewTerms');
|
$route->setDefault('_form', 'Drupal\taxonomy\Form\OverviewTerms');
|
||||||
$route->setRequirement('_entity_access', 'taxonomy_vocabulary.access taxonomy overview');
|
$route->setRequirement('_entity_access', 'taxonomy_vocabulary.access taxonomy overview');
|
||||||
$route->setOption('_admin_route', TRUE);
|
$route->setOption('_admin_route', TRUE);
|
||||||
|
$route->setOption('parameters', [
|
||||||
|
'taxonomy_vocabulary' => [
|
||||||
|
'with_config_overrides' => TRUE,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
return $route;
|
return $route;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\taxonomy\Functional;
|
namespace Drupal\Tests\taxonomy\Functional;
|
||||||
|
|
||||||
|
use Drupal\language\Entity\ConfigurableLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests content translation for vocabularies.
|
* Tests content translation for vocabularies.
|
||||||
*
|
*
|
||||||
|
@ -12,13 +14,20 @@ class VocabularyTranslationTest extends TaxonomyTestBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $modules = ['content_translation', 'language'];
|
protected static $modules = ['content_translation', 'language', 'config_translation'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected $defaultTheme = 'stark';
|
protected $defaultTheme = 'stark';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Languages to enable.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $additionalLangcodes = ['es'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +38,13 @@ class VocabularyTranslationTest extends TaxonomyTestBase {
|
||||||
$this->drupalLogin($this->drupalCreateUser([
|
$this->drupalLogin($this->drupalCreateUser([
|
||||||
'administer taxonomy',
|
'administer taxonomy',
|
||||||
'administer content translation',
|
'administer content translation',
|
||||||
|
'translate configuration',
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
// Add languages.
|
||||||
|
foreach ($this->additionalLangcodes as $langcode) {
|
||||||
|
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,4 +70,51 @@ class VocabularyTranslationTest extends TaxonomyTestBase {
|
||||||
$this->assertSession()->checkboxChecked('edit-default-language-content-translation');
|
$this->assertSession()->checkboxChecked('edit-default-language-content-translation');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests vocabulary name translation for the overview and reset pages.
|
||||||
|
*/
|
||||||
|
public function testVocabularyTitleLabelTranslation(): void {
|
||||||
|
$this->drupalGet('admin/structure/taxonomy/add');
|
||||||
|
|
||||||
|
// Create the vocabulary.
|
||||||
|
$vid = mb_strtolower($this->randomMachineName());
|
||||||
|
$edit['name'] = $this->randomMachineName();
|
||||||
|
$edit['description'] = $this->randomMachineName();
|
||||||
|
$edit['langcode'] = 'en';
|
||||||
|
$edit['vid'] = $vid;
|
||||||
|
$edit['default_language[content_translation]'] = TRUE;
|
||||||
|
$this->submitForm($edit, t('Save'));
|
||||||
|
|
||||||
|
$langcode = $this->additionalLangcodes[0];
|
||||||
|
$vid_name = $edit['name'];
|
||||||
|
$translated_vid_name = "Translated $vid_name";
|
||||||
|
|
||||||
|
$this->assertSession()->pageTextContains($vid_name);
|
||||||
|
|
||||||
|
// Assert that the name label is displayed on the translation form with the
|
||||||
|
// right value.
|
||||||
|
$this->drupalGet("admin/structure/taxonomy/manage/$vid/translate/$langcode/add");
|
||||||
|
|
||||||
|
// Translate the name label.
|
||||||
|
$this->submitForm(["translation[config_names][taxonomy.vocabulary.$vid][name]" => $translated_vid_name], t('Save translation'));
|
||||||
|
|
||||||
|
// Assert that the right name label is displayed on the taxonomy term
|
||||||
|
// overview page. The translations are created in this test; therefore, the
|
||||||
|
// assertions do not use t(). If t() were used then the correct langcodes
|
||||||
|
// would need to be provided.
|
||||||
|
$this->drupalGet("admin/structure/taxonomy/manage/$vid/overview");
|
||||||
|
$this->assertSession()->pageTextContains($vid_name);
|
||||||
|
$this->drupalGet("$langcode/admin/structure/taxonomy/manage/$vid/overview");
|
||||||
|
$this->assertSession()->pageTextContains($translated_vid_name);
|
||||||
|
|
||||||
|
// Assert that the right name label is displayed on the taxonomy reset page.
|
||||||
|
// The translations are created in this test; therefore, the assertions do
|
||||||
|
// not use t(). If t() were used then the correct langcodes would need to be
|
||||||
|
// provided.
|
||||||
|
$this->drupalGet("admin/structure/taxonomy/manage/$vid/reset");
|
||||||
|
$this->assertSession()->pageTextContains($vid_name);
|
||||||
|
$this->drupalGet("$langcode/admin/structure/taxonomy/manage/$vid/reset");
|
||||||
|
$this->assertSession()->pageTextContains($translated_vid_name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue