Multilingual tokens are not translated

Created on 27 October 2022, over 2 years ago
Updated 2 April 2023, about 2 years ago

Problem/Motivation

When sending out multilingual newsletters, multilingual tokens are not translated - specifically [simplenews-newsletter:name] in the subject was not translated and the Unsubscribe link in the body included /en in the url.

Steps to reproduce

To recreate:

1. Create a site with English as the default language and French as the second language or use the DrupalWxT distribution
2. Enable the simplenews module
3. Created two subscribers (non-authenticated), one English and one French
4. Create a newsletter type "myEn" and translate the name to "myFr"
- leave the subject as: [[simplenews-newsletter:name]] [node:title]
5. Create a newsletter, translate it and send it out!

Result for the French subscriber:
1. The email subject will contain the correct French node title but will incorrectly be prefaced by [myEn];
2. The last line of the email will include an unsubscribe link with /en in the url.

Proposed resolution

Ensure the token code handles language properly.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada joel_osc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thanks for the report and patch. I'm the only active maintainer and I don't use multi-lingual๐Ÿ˜ƒ - it would be great if someone else could test.

    The patch looks correct to me, it could be tidied up a little:

    1. Instead of \Drupal::service('language_manager'); use \Drupal::languageManager()
    2. Use the $language_manager variable within the loop
    3. Can the translation really be missing a name? Even if yes, can simplify the code with ?? operator.
    4. The 'sanitize' option was removed in Drupal 8๐Ÿ˜ƒ - as we are changing the code, let's delete that part
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    59 pass
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine vlad.dancer Kyiv

    Here is patch with addressed comments from #6

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Great thanks. All patches now need to go into v4 please. Sorry the tokens code has changed and it will need some editing in the re-roll.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    34 pass, 6 fail
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Rerolled patch #7 for the 4.x-dev branch, please review it.

    Thanks!

  • First commit to issue fork.
  • Pipeline finished with Failed
    3 months ago
    Total: 154s
    #410648
  • MP 82 contains a test covering the problem and changes to fix it.

    I would like to highlight some important points:

    1. the fix only solves the problem with the newsletter name
    2. it is not clear how relevant the URL token is. I updated the code so that there are no errors and left a todo. We can discuss what to do with this
    3. the problem with respecting the language in links remains and it is general, as it applies to other links as well. I will create a new task and would suggest fixing this in the new task.
  • Pipeline finished with Failed
    3 months ago
    Total: 652s
    #410657
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thanks. As I put in a comment in the MR - I feel we could just delete the url token.

  • Pipeline finished with Canceled
    3 months ago
    Total: 164s
    #417000
  • Pipeline finished with Failed
    3 months ago
    Total: 517s
    #417003
  • Pipeline finished with Failed
    3 months ago
    Total: 509s
    #417025
  • Pipeline finished with Success
    3 months ago
    Total: 683s
    #417178
  • @adamps, ready to review with final fixes:

    • fixed problem with newsletter name translation
    • fixed problem with respecting subscriber's language in action urls
  • Pipeline finished with Skipped
    3 months ago
    #418527
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Great thanks everyone

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

Production build 0.71.5 2024