Skip to content
Snippets Groups Projects

[#2137815] InvalidArgumentException: Invalid translation language specified.

Open [#2137815] InvalidArgumentException: Invalid translation language specified.
6 unresolved threads
Open Deepak Sagar requested to merge issue/drupal-2137815:11.x into 11.x
6 unresolved threads

Closes [#2137815]

Edited by Alex Pott

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
397 397 /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
398 398 $entity = $route_match->getParameter($entity_type_id);
399 399
400 // If the entity already has the target translation, redirect to the
401 // translation overview page.
402 if ($entity->hasTranslation($target->getId())) {
403 return $this->redirect("entity.$entity_type_id.content_translation_overview", [$entity_type_id => $entity->id()]);
404 }
  • Comment on lines +400 to +404

    Is this the correct behaviour? The original request for this behaviour mentioned at least adding a message telling the user what had happened. But I don't understand the rationale for going to the translation overview page instead of the edit page for the translation which is surely closer to the user intended.

  • Please register or sign in to reply
  • 120 120 $this->assertSession()->responseContains('<span class="translation-entity-all-languages">(all languages)</span>');
    121 121 }
    122 122
    123 // Asserts that once a translation exists the user is redirected to the
    124 // translations overview page.
    125 if ($entity_type_id === 'entity_test_mul_changed') {
    126 $this->drupalGet($add_url);
    127 $this->assertSession()->statusCodeEquals(200);
    128 $this->assertSession()->pageTextContains('Translations');
    129 $this->assertStringContainsString('/entity_test_mul_changed/manage/1/translations', $this->getUrl());
    130 // Ensure the redirect works also for user 1.
    131 $this->drupalLogin($this->rootUser);
    132 $this->drupalGet($add_url);
    133 $this->assertSession()->statusCodeEquals(200);
    134 $this->assertSession()->pageTextContains('Translations');
    135 $this->assertStringContainsString('/entity_test_mul_changed/manage/1/translations', $this->getUrl());
  • 366 366 $title = $this->entityFormTitle($entity);
    367 367 // When editing the original values display just the entity label.
    368 368 if ($is_translation) {
    369 $t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title];
    369 $t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label() ?? $entity->id(), '@title' => $title];
    • Comment on lines -369 to +369

      These changes to use entity ID instead of the label when the label is null feel out-of-scope. I guess that they are caused by testing with an entity with no title. I think we should add a title to that entity instead of doing this fix like this. I think we should handle NULL labels in a different and fuller way. Making these changes here will result in a piecemeal approach.

    • Please register or sign in to reply
  • 51 51 */
    52 52 protected function entityFormTitle(EntityInterface $entity) {
    53 53 $type_name = node_get_type_label($entity);
    54 return t('<em>Edit @type</em> @title', ['@type' => $type_name, '@title' => $entity->label()]);
    54 return t('<em>Edit @type</em> @title', ['@type' => $type_name, '@title' => $entity->label() ?? $entity->id()]);
  • 71 71 'bypass node access',
    72 72 'administer nodes',
    73 73 'translate any entity',
    74 'create content translations',
  • 117 117 * Returns an array of permissions needed for the translator.
    118 118 */
    119 119 protected function getTranslatorPermissions() {
    120 return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations']);
    120 return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations', 'translate any entity']);
  • Alex Pott changed title from Update 4 files to [#2137815] InvalidArgumentException: Invalid translation language specified.

    changed title from Update 4 files to [#2137815] InvalidArgumentException: Invalid translation language specified.

  • Alex Pott changed the description

    changed the description

  • robin.houtevelts added 2470 commits

    added 2470 commits

    Compare with previous version

  • Please register or sign in to reply
    Loading