The token [webform_submission:node:title] takes always the title of the original sitetitle. On a multiple language website it didn't take the translated titel of the page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zeroplexer created an issue. See original summary.

jrockowitz’s picture

Priority: Normal » Critical
Status: Active » Needs review
FileSize
1.22 KB

I can replicate this issue which is the source entity is always the default language.

The attached patch returns the translated source entity when \Drupal\webform\Entity\WebformSubmission::getSourceEntity is called, this fixes the token issue.

This solution translated all submissions related URLs.

/node/{nid}/webform/submissions => /es/node/{nid}/webform/submissions.
/node/{nid}/webform/submission/{sid} => /es/node/{nid}/webform/submission/{sid}.

We might have just discovered a much bigger issue where a translated submission can only be viewed in the default language.

Fixing this issue could cause make problems and regressions for people who are relying on the broken untranslated URLs.

My only immediate thought is that we could add redirects from the broken translated submissions URLs to the correct ones.

Status: Needs review » Needs work

The last submitted patch, 2: 2980963-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review

The attached patch only fixes the token source entity translation issue. This approach should not break any tests or cause regressions.

I have decided not always translate the source entity because there is one major nuance to webform submission translations, which is that webform submissions are multilingual, but they are not translatable. In other words, only one language is associated with one submission I am not sure it makes sense to change the entire site's language when an admin views a single submission.

We can also address this issue in a new ticket.

jrockowitz’s picture

jrockowitz’s picture

The attached patch adds test coverage.

  • jrockowitz committed 85d699c on 8.x-5.x
    Issue #2980963 by jrockowitz: [webform_submission:node:title] don't take...
  • jrockowitz committed debc950 on 8.x-5.x
    Issue #2980963 by jrockowitz: [webform_submission:node:title] don't take...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.