VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: vmfyelloq19 on March 29, 2022, 11:33:10 AM

Title: vmText loses translations during checkout. Bug?
Post by: vmfyelloq19 on March 29, 2022, 11:33:10 AM
I'm investigating a strange behaviour in 3.8.8 10472
Somehow all vmlang translations seem to get lost at some point.
I've attached the code I used to trace down the problem.

Template override for checkout in in templates/mytemplate/html/com_virtuemart.

Works:
<?php
// cart/default.php
defined('_JEXEC') or die('');
echo __FILE__ . ' #' . __LINE__ . ' ' . vmText::_ ('COM_VIRTUEMART_SAVE') . ' | ' . vmText::_ ('COM_VIRTUEMART_CANCEL') . '<br>'; // OK, translated
// [...]


Problems:
a) In the template override file's function renderControlButtons(), vmlanguages are not available anymore initiallay, I have to vmLanguage::loadJLang(...) them now.
b) Using Jroute::_() drops translations

<?php
// user/edit_address.php
defined('_JEXEC') or die('');
echo __FILE__ . ' #' . __LINE__ . ' ' . vmText::_ ('COM_VIRTUEMART_SAVE') . ' | ' . vmText::_ ('COM_VIRTUEMART_CANCEL') . '<br>'; // COM_VIRTUEMART_SAVE | COM_VIRTUEMART_CANCEL
vmLanguage::loadJLang('com_virtuemart', $_frontend=true, JFactory::getLanguage()->getTag(), $_cache=true);
echo __FILE__ . ' #' . __LINE__ . ' '  .vmText::_ ('COM_VIRTUEMART_SAVE') . ' | ' . vmText::_ ('COM_VIRTUEMART_CANCEL') . '<br>'; // OK, translated
JRoute::_ ('index.php?option=com_virtuemart&view=' . $rview.'&task=cancel'); // This seems to drop all language definitions!
echo __FILE__ . ' #' . __LINE__ . ' '  .vmText::_ ('COM_VIRTUEMART_SAVE') . ' | ' . vmText::_ ('COM_VIRTUEMART_CANCEL') . '<br>'; // COM_VIRTUEMART_SAVE | COM_VIRTUEMART_CANCEL
vmLanguage::loadJLang('com_virtuemart', $_frontend=true, JFactory::getLanguage()->getTag(), $_cache=true);
echo __FILE__ . ' #' . __LINE__ . ' '  .vmText::_ ('COM_VIRTUEMART_SAVE') . ' | ' . vmText::_ ('COM_VIRTUEMART_CANCEL') . '<br>'; // OK again
// [...]



This seems to be a vmLang problem, using JText::_() instead fo vmText::_() works as expected everywhere.

Title: Re: vmText loses translations during checkout. Bug?
Post by: Milbo on March 30, 2022, 19:50:31 PM
Hmmm, please create a backup and use our new RC, which should be our final next days
https://dev.virtuemart.net/attachments/1305/com_virtuemart.3.8.9.10622_package_or_extract.zip
Title: Re: vmText loses translations during checkout. Bug?
Post by: vmfyelloq19 on April 01, 2022, 17:42:43 PM
Thanks Milbo.

Installing an RC on a production shop is probably a bit risky ;-)
As I have template overrides in place anyway I'll stick to JText::_() for now.

I might have the dev system available for testing soon, so I might try the RC there.
Can you confirm the problem or do I need to investigate if anything obscure on our side is causing th issue?

Since we're at the optictopic: what is the reason for replicating JText:__() in Virtuemart? I never found out when to use what.