News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Virtuemart sometimes erroneously defaults to English

Started by at, November 10, 2018, 19:48:38 PM

Previous topic - Next topic

at

Hi,

Recently our Multilanguage shop started behaving weirdly. We're using Virtuemart 3.4.2 on Joomla 3.9.0 (powered by the latest php7) and a custom template.

The default language is English. But if I switch to Russian and do some changes in the cart, e.g. change product quantity and click 'update', VM should show a warning in the language of the user interface. It should say "Warning" and then warning text, both in UI language. However, "Warning" is shown in Russian but warning text in English. I went to vmInfo() function and changed line 57 from $msg = vmText::_($publicdescr) to $msg = vmText::_($publicdescr) . '  ' . JText::_($publicdescr). And repeated the action in the cart. This time, the text generated by vmText was wrongly in English, but the text generated by JText was correctly in Russian.

Related to that, if I go to account management in the front-end, the form for creating a new account is shown. If I'm in the Russian version of the website, it's in Russian. However, when I click the Cancel button on the form, this same form is shown again with Russian header, but this time, all field labels are in English.

The categories and products, however, are still shown in the correct language. The cart is shown in the correct language. So it's not that everything is broken. It seems that in some cases, Virtuemart thinks the user views the English version of the website when in fact it's not the case.

What could have gone wrong? I can't trace it to a particular action, but this for sure happened after updating Joomla to 3.9.0. Not sure whether installing another Virtuemart frontend language could have caused this.

GJC Web Design

first stage is to use the VM debugging to test the what VM thinks its lang is...

and test what $lang = vmLanguage::getLanguage();  is in administrator\components\com_virtuemart\helpers\config.php  function vmInfo()
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

at

Well, $lang in vmInfo() references everything related to en-GB, the website's default language, regardless what's the actual UI language.

GJC Web Design

Then we must assume this is a bug?

Max reads all these posts so will probably respond further
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

at

Just came across this issue again and thought I should have shared the workaround I used when starting this thread. This workaround worked again.

The main issue is that -- for unknown reason -- on the Cart page, vmText::_() shows only the default language, while JText::_() shows the correct translation to the actual UI language. So changing vmText to JText in cart-related PHP code solves the issue.

Not sure why this happens on the latest VM 3.4.2 only on the Cart page. Also not sure whether it happens only in my case or for other users too.