URL does not respect current language

Created on 2 April 2024, 9 months ago

Problem/Motivation

Contrary to the project description page, the module does not respect the current language, as defined on admin/config/regional/language/detection/url.

Steps to reproduce

Follow the instructions on the project page and add the base_url replacement token to the output of a link. The langcode is not present in the outputted link path.

Proposed resolution

When examining the render function in BaseUrl.php at line 172, the $language variable is defined as:

global $language;

This is Drupal 7 syntax and is obsolete. The correct Drupal 8+ syntax is:

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

However, this change does not remedy the problem. The link creation code starting at line 210 needs further refinement.

Remaining tasks

Fully implement support of the inclusion of the langcode in the URL. This include respecting when the default langcode is not defined and left blank via admin/config/regional/language/detection/url.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States johnhanley

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

Comments & Activities

Production build 0.71.5 2024