User tests: Successful: Unsuccessful:
Pull Request for Issue #23144 (That issue has a wrong title)
When "Remove URL Language Code" is set to ON in the language filter plugin, the url produced for the default site language does not include the url language code.
Example on a site with fr-FR, en-GB and it-IT.
en-GB is set as default site language
Resulting urls will contain
mysite.com/
for en-GB
mysite.com/fr/
for fr-FR
mysite.com/it/
for it-IT
Before this patch, the source of the page was still showing the /en/
url language code for the part of the code concerning mod_languages flag/name link.
This has no effect on the final url but it may have some effects for crawlers as they look at all urls in a page source and therefore follow the redirect.
This patch modifies the code for the switcher in order to take off the url language code in source when necessary.
Create a multilingual site with associations.
Make sure you set "Remove URL Language Code" to ON in the Language Filter system plugin
Display frontend, hover the flag/name of the site default language in the language switcher module.
This on the home page as well as some associated pages.
for the home (but would be similar for other pages)
Status | New | ⇒ | Pending |
Category | ⇒ | Modules Front End |
Labels |
Added:
?
|
A question: why instead of re-defining setLanguagecookie() not setting it public in languagefilter? It would be better maintenable, no?
There must have been a reason why it was set private in the language filter.
Anyway it uses $this
which would not fit here.
IMO this is an easier way. Can you check.
diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php
index 7ab830b308..671d2cdcb8 100644
--- a/plugins/system/languagefilter/languagefilter.php
+++ b/plugins/system/languagefilter/languagefilter.php
@@ -224,8 +224,7 @@ class PlgSystemLanguageFilter extends JPlugin
if ($this->mode_sef
&& (!$this->params->get('remove_default_prefix', 0)
- || $lang !== $this->default_lang
- || $lang !== $this->current_lang))
+ || $lang !== $this->default_lang))
{
$uri->setPath($uri->getPath() . '/' . $sef . '/');
}
Ups, my patch does not work in all cases.
Ups, my patch does not work in all cases.
yep, was going to say that. ;)
BTW, please also look at this other issue concerning trailing slash:
#23209 (comment)
hi, another successful tester is needed, or.. are there doubts on the PR code?
I am not convinced of this solution, but I do not have time to find a better way.
@infograf768 Can you at least change in the code from public static function setLanguageCookie($languageCode)
to private static function setLanguageCookie($languageCode)
?
After someone finds a better way, then we can delete this method.
Will check today.
I am closing this because the cookie may also be set when not desired.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-14 11:13:48 |
Closed_By | ⇒ | infograf768 |
I have tested this item✅ successfully on 81bedb7
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23178.