Can't switch to default language. possible bug?

General questions regarding the use of languages in Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Can't switch to default language. possible bug?

Post by infograf768 » Mon Feb 23, 2015 10:03 am

Force loading the site in the default site language in the language filter system plugin parameters. This will work when first loading the site. Thereafter, as a cookie is set, it could load in the last language displayed.
Screen Shot 2015-02-23 at 11.03.02.png
You do not have the required permissions to view the files attached to this post.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

electrocity
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Mar 06, 2010 8:21 pm
Contact:

Re: Can't switch to default language. possible bug?

Post by electrocity » Fri Feb 03, 2017 2:28 am

Note that this is not solved in Joomla 3.6.5. (3 year later!)
I wrote a little fix for a customer removing the session value from the test using a new value in the parameters and used in file
JOOMLAROOT\plugins\system\languagefilter\languagefilter.php line 281

Code: Select all

				// Check if remove default url language code is set
				if ($this->params->get('remove_default_prefix', 0))
				{
					if ($parts[0])
					{
						// We load a default site language page
						$lang_code = $this->default_lang;
					}
					elseif($this->params->get('lang_cookie', 0) == 2)
					{
					//STUDIO42 hack this permit to switch from and to default language
						$lang_code = $this->default_lang;
					} 
					else
					{
						// We check for an existing language cookie
						$lang_code = $this->getLanguageCookie();
					}
				}
Note that currently if you are not in default language, the language module link have the lang tag in the link,so i adjusted my Virtuemart language module switcher to remove the lang tag in the link for default too to never have defualt lang in the links.

Code: Select all

$this->params->get('lang_cookie', 0) == 2
use an unexisting value

in the languagefilter.XML i used:

Code: Select all

				<field
					name="lang_cookie"
					type="list"
					label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_COOKIE_LABEL"
					description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_COOKIE_DESC"
					default="0"
					>
					<option value="1">PLG_SYSTEM_LANGUAGEFILTER_OPTION_YEAR</option>
					<option value="0">PLG_SYSTEM_LANGUAGEFILTER_OPTION_SESSION</option>
					<option value="2">JNONE</option>
				</field>
It's not perfect using JNONE but it' not important for my customer.
Free and paid Joomla & virtuemart extensions https://shop.st42.fr/en

Henrique Franze
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue May 03, 2016 6:48 pm

Re: Can't switch to default language. possible bug?

Post by Henrique Franze » Wed Feb 15, 2017 1:49 pm

Electrocity I using joomla 3.6.5
pt-BR <- default (tag br)
en-US <-alternative (tag en)

when Remove URL Language Code in language filter plugin is set to YES:

Front end user logoff => I can switch between languages, when switch from en to pt site redirects removing the /pt/ from url, works fine.

Front end user Logged in => when switch from en to pt, site does not redirect and get 404 error =(

Can you help?

Thanks.

electrocity
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Mar 06, 2010 8:21 pm
Contact:

Re: Can't switch to default language. possible bug?

Post by electrocity » Wed Feb 15, 2017 3:16 pm

Hi Henrique,
Have you test with my changes?
Free and paid Joomla & virtuemart extensions https://shop.st42.fr/en

Henrique Franze
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue May 03, 2016 6:48 pm

Re: Can't switch to default language. possible bug?

Post by Henrique Franze » Wed Feb 15, 2017 4:01 pm

Hi,

Yes, I have and not work when I login in the frontend.

I CTRL+V the elseif to my code it did't help.

Actually there is several places where the code check the user language, exemple after line 400, but I can't realize where:

Code: Select all

// Lets find the default language for this user
			if (!isset($lang_code) || !isset($this->lang_codes[$lang_code]))
			{
				$lang_code = false;

				if ($this->params->get('detect_browser', 1))
				{
					$lang_code = JLanguageHelper::detectLanguage();

					if (!isset($this->lang_codes[$lang_code]))
					{
						$lang_code = false;
					}
				}

				if (!$lang_code)
				{
					$lang_code = $this->default_lang;
				}
			}

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Can't switch to default language. possible bug?

Post by infograf768 » Wed Feb 15, 2017 4:43 pm

@Henrique Franze
If you like you can send me a mail through my profile with the necessary Super User credentials and the url of your site and I will have a look.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

electrocity
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Mar 06, 2010 8:21 pm
Contact:

Re: Can't switch to default language. possible bug?

Post by electrocity » Thu Feb 16, 2017 12:17 pm

Hi infograf,
Most time i send my problem or solution in French forum, i think that the languague switching is not right if you need to display same articles for all in the index file.
Most time the Joomla site owner need.
Default home with language for FR = french article only and always
Home with language for EN = English articles only and always
But if you are in the home and remove the prefix and are connected as english user and default language is French, this not work and same if you switch back from another language to default language in Home.
If you disable the language filter plugin then nothing is filtered including modules ...
So currently you have a case that cannot be solved: switching to default language home and not use session language but home language without prefix.
Free and paid Joomla & virtuemart extensions https://shop.st42.fr/en

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Can't switch to default language. possible bug?

Post by infograf768 » Fri Feb 17, 2017 7:10 am

@electrocity
Sorry to say, but I do not understand at all what you say.

What means:
"i think that the language switching is not right if you need to display same articles for all in the index file."
I have specially no idea what you mean by the "index file", and what are these "same articles".

Please try to post here the exact structure of your site
Categories, tagged to which language.
Articles concerned, tagged to which language, belonging to which category.
Type of Menu items, specially the Home menu item for each language.
Associations implemented for the categories, articles, and menu items.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

electrocity
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Mar 06, 2010 8:21 pm
Contact:

Re: Can't switch to default language. possible bug?

Post by electrocity » Fri Feb 17, 2017 11:21 am

Sorry i write in french so you understand better Jean-Marie.
Dans la page d'accueil, il faudrait pouvoir désactiver la langue de l'utilisateur(session) et toujours utilisé celle du site. Actuellement il n'y a pas ce choix et un utilisateur ayant une langue dans la session ne peut plus voir les articles d'une langue par défaut dans l'accueil(ou tout composant utilisant la langue comme filtre)
Donc si le filtre est actif et que l'accueil est en français et que l'utilisateur se connecte en Anglais, l'affichage est mauvais si on désactive l'utilisation du prefix.
SI on laisse le prefix actif, alors ça fonctionne car le préfixe switch la langue en français. Mais je pense que le comportement de Joomla devrait être le même dans tout les cas (avec ou sans préfixe de langue).
Cordialement,
Patrick
Free and paid Joomla & virtuemart extensions https://shop.st42.fr/en

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Can't switch to default language. possible bug?

Post by infograf768 » Fri Feb 17, 2017 3:32 pm

We have to write in English in the English forums.

1. For a guest using for example a pure domain url http: //mydomain.com, Joomla will try to display the home page in the same language as the browser or use the default site language depending on the Language Selection for New Visitors.
2. The session language is created —whatever the user default site language— each time one switches languages.
3. The user default site language is ONLY used when a user logs in: on the home page or when the page displays an item associated to an item tagged to the same language as the user default site language. This ONLY when Automatic Language Change is implemented in the languagefilter plugin.
4. Once logged in, switching languages through the language switcher module or through another well conformed link in content will change the session language.
5. The prefix can only be taken of for the site default language when Remove URL Language Code is set.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group


Locked

Return to “Language - Joomla! 3.x”