VirtueMart Forum

VirtueMart 2 + 3 + 4 => Language/Translations => Topic started by: at on November 10, 2018, 19:48:38 PM

Title: Virtuemart sometimes erroneously defaults to English
Post by: at on November 10, 2018, 19:48:38 PM
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.
Title: Re: Virtuemart sometimes erroneously defaults to English
Post by: GJC Web Design on November 11, 2018, 10:41:59 AM
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()
Title: Re: Virtuemart sometimes erroneously defaults to English
Post by: at on November 11, 2018, 11:41:22 AM
Well, $lang in vmInfo() references everything related to en-GB, the website's default language, regardless what's the actual UI language.
Title: Re: Virtuemart sometimes erroneously defaults to English
Post by: GJC Web Design on November 11, 2018, 12:19:15 PM
Then we must assume this is a bug?

Max reads all these posts so will probably respond further
Title: Re: Virtuemart sometimes erroneously defaults to English
Post by: at on June 09, 2019, 13:08:16 PM
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.