[solved]update 3.6.8 10197 the categories and products do not change language

Started by elanto75, November 08, 2019, 15:03:33 PM

Previous topic - Next topic

Milbo

Damn, that thing again.

Any plugins, which load/use vm files before the core is executed should load the config with

loadConfig($force = FALSE,$fresh = FALSE, $lang = true, $exeTrig = true)

and with correct parameters for that case:

loadConfig(FALSE,FALSE, false, false);


Then it will work correct. VM takes itself the already loaded config and just initialises the language and executes the trigger. I will directly add that to some dev docs tutorial.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

elanto75

Quote from: Studio 42 on November 22, 2019, 18:54:41 PM
For other users having this problem.
The bug was because a plugin loaded the vmconfig before the language was set.
So reording the system plugin so Joomla language plugin is loaded first should solve the bug.

Thank you, your help was really precious!

balai

QuoteloadConfig($force = FALSE,$fresh = FALSE, $lang = true, $exeTrig = true)
This does not solve the problem in all the cases.

Actual Case:
If the plugin calls the \vmConfig::loadConfig function as a preloader (outside the plugin's main class), then the loadConfig is called during the importPlugin function, when the application loads all the plugin files (of type system). I.e. Before triggering them.
In that case the loadConfig is called before the languageCode plugin (no matter their order) and as a result sets the default language as the VM's language.
Now since you have the language as a static param in the vmText Class, it makes no difference if the Application's language is defined later by the languageCode system plugin. It is already defined for VM in the 1st call.

Question:
What if the vmText gets the current language from the application instead of using a static variable?
$lang=\Joomla\CMS\Factory::getApplication()->getLanguage();
This seems to work independently of any plugin's code.
Also why not letting the application have responsibility of it's own variables?
This is a variable that affects the state of the entire application. It is not wise to store it statically in higher level.

Studio 42

The plugin is not "languageCode plugin" but "System - Language Filter".
You need to order this plugin first in the list.