Skip to content

[6.0] Multilingual: Fix language passed via lang variable is ignored#46810

Merged
Bodge-IT merged 2 commits intojoomla:6.0-devfrom
joomdonation:fix_language_is_ignored
Feb 5, 2026
Merged

[6.0] Multilingual: Fix language passed via lang variable is ignored#46810
Bodge-IT merged 2 commits intojoomla:6.0-devfrom
joomdonation:fix_language_is_ignored

Conversation

@joomdonation
Copy link
Copy Markdown
Contributor

Pull Request for Issue # .

Summary of Changes

In Joomla 5.4 and earlier, language passed via lang variable is always used (takes highest priority) in language filter plugin (see https://github.com/joomla/joomla-cms/blob/5.4-dev/plugins/system/languagefilter/src/Extension/LanguageFilter.php#L412).

In Joomla 6.0, due to the change in this PR #43858, if Remove URL Language Code parameter set to Yes in System - Language Filter plugin, Joomla will use default language if it could not detect language from sef URL, not respect the language passed in lang variable when it is passed. This PR just fixes that wrong (backward incompatible) change.

Testing Instructions

  • Uses Joomla 6.0 (any version)
  • Setup a multilingual website with two languages (default is English and one additional language like German). You can Sample Data - Multilingual to setup test site faster if needed.
  • Go to System -> Plugins, find System - Language Filter plugin, set Remove URL Language Code parameter to Yes
  • Access to homepage of your site and appends ?lang=de to URL, for example http://localhost/joomla/index.php?lang=de

Actual result BEFORE applying this Pull Request

  • The site in default language (English in this case is displayed). It ignore the language passed in lang variable (when lang is passed, site should be displayed in the passed language - German in this example, same behavior with Joomla 5.4 and earlier)

Expected result AFTER applying this Pull Request

  • Site is displayed in the expected language passed via lang variable in URL (German in this example) like in Joomla 5.4 and earlier Joomla version

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@exlemor
Copy link
Copy Markdown

exlemor commented Feb 1, 2026

@joomdonation is it because my test website is in a subfolder that

https://www.domain.com/_j6b2n/index.php?lang=fr - shows French version
https://www.domain.com/_j6b2n/index.php?lang=en - shows English version

WITHOUT the PR applied while having the System - Language Filter plugin --> set Remove URL Language Code parameter to Yes or is it because I have the Language Filter settings set this way (beyond the Remove URL Language Code set to Yes I mean)

ScreenFloat Shot of Safari on 2026-02-01 at 20-16-08

Thanks for the clarification :)

@joomdonation
Copy link
Copy Markdown
Contributor Author

Thanks @exlemor for testing. No, sub-folder is not effected because that happens on my local Joomla installation, too and I can clearly see the issue by code reading. It is strange that it is working OK on your test site. Just want to be sure, the site is a fresh Joomla 6 installation (because the issue only happens with Joomla 6, it works well on Joomla 5.4 and earlier)

@ceford
Copy link
Copy Markdown
Contributor

ceford commented Feb 3, 2026

I have tested this item ✅ successfully on 130a29a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46810.

@mariantanase
Copy link
Copy Markdown

I have tested this item ✅ successfully on 130a29a

Site is displayed correctly in the expected language passed via lang variable in URL, in my case italian language (/index.php?lang=it).
Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46810.

@exlemor
Copy link
Copy Markdown

exlemor commented Feb 3, 2026

Thanks @exlemor for testing. No, sub-folder is not effected because that happens on my local Joomla installation, too and I can clearly see the issue by code reading. It is strange that it is working OK on your test site. Just want to be sure, the site is a fresh Joomla 6 installation (because the issue only happens with Joomla 6, it works well on Joomla 5.4 and earlier)

Hi @joomdonation, it is a Joomla 6 Nightly Site from the day before, and I just retested and it works without the PR applied. :/

@joomdonation
Copy link
Copy Markdown
Contributor Author

Hi @joomdonation, it is a Joomla 6 Nightly Site from the day before, and I just retested and it works without the PR applied.

That's strange because I can see the issue, both by actual test and code reading :). @Fedik @Hackwar You two worked on the most recent changes for the plugin, would be great if you could do a code review for this PR. Thanks.

@Fedik
Copy link
Copy Markdown
Member

Fedik commented Feb 4, 2026

Hm, I do not see how this changes may work.

The default lang will be overrided in few line down, when it is correct:

// The language was set both per SEF path and per query parameter. Query parameter takes precedence
if ($lang && isset($this->sefs[$sef])) {
$uri->setVar('lang', $lang);
$router->setTainted();
}

With your changes for URL with ?lang=foobar the default language will not be set.

I did not tested, just looking the code. Maybe I missed something.

@joomdonation
Copy link
Copy Markdown
Contributor Author

The default lang will be overrided in few line down, when it is correct:

For a none SEF URL like https://domain.com/index.php?option=com_name&task=do_something&lang=de for example, $sef is empty, so isset($this->sefs[$sef]) return false, so lang is not set in that block

In my specific case, there is AJAX post request made to a none SEF url like above, the wrong language is use and cause wrong behavior.

@Fedik
Copy link
Copy Markdown
Member

Fedik commented Feb 4, 2026

Okay, then it seems makes sense.

@joomdonation
Copy link
Copy Markdown
Contributor Author

Okay, then it seems makes sense.

Thanks

@joomdonation
Copy link
Copy Markdown
Contributor Author

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46810.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 4, 2026
@Bodge-IT Bodge-IT added this to the Joomla! 6.0.3 milestone Feb 5, 2026
@Bodge-IT Bodge-IT merged commit 2cb1f00 into joomla:6.0-dev Feb 5, 2026
99 of 100 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 5, 2026
@Bodge-IT
Copy link
Copy Markdown
Contributor

Bodge-IT commented Feb 5, 2026

Thanks for the fix @joomdonation and thanks @mariantanase and @ceford for time offered for testing

@joomdonation
Copy link
Copy Markdown
Contributor Author

Thanks to all !

@joomdonation joomdonation deleted the fix_language_is_ignored branch February 5, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants