- Issue created by @andre.bonon
- 🇧🇷Brazil andre.bonon
https://www.drupal.org/project/simplenews/issues/3534572 🐛 Unsubscribe link uses outdated 'langcode' option in Url::fromRoute(), resulting in incorrect language in generated URL Active
The simplenews_generate_url() function currently builds unsubscribe links using the langcode option in the $options array passed to Url::fromRoute():
$url_arguments = ['absolute' => TRUE, 'langcode' => $subscriber->getLangcode()];
...
return Url::fromRoute("simplenews.subscriptions_$action", $route_parameters, $url_arguments)->toString();
The langcode key is not supported for generating translated URLs using Url::fromRoute(). The correct and recommended way is to use the language key and pass an instance of \Drupal\Core\Language\LanguageInterface.
Because of this, the unsubscribe link may not include the expected language prefix (e.g., /fr), and subscribers receive links in the default site language instead of their preferred language.
Use the right language key.
Active
4.1
Code
https://www.drupal.org/project/simplenews/issues/3534572 🐛 Unsubscribe link uses outdated 'langcode' option in Url::fromRoute(), resulting in incorrect language in generated URL Active