Author Topic: [solved]update 3.6.8 10197 the categories and products do not change language  (Read 3965 times)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10144
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: update 3.6.8 10197 the categories and products do not change language
« Reply #15 on: November 22, 2019, 19:38:46 pm »
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

  • Beginner
  • *
  • Posts: 23
  • Skype Name: elanto75
Re: update 3.6.8 10197 the categories and products do not change language
« Reply #16 on: November 25, 2019, 15:09:21 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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1459
Quote
loadConfig($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?
Code: [Select]
$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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4518
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
The plugin is not "languageCode plugin" but "System - Language Filter".
You need to order this plugin first in the list.