News:

Support the VirtueMart project and become a member

Main Menu

vmText loses translations during checkout. Bug?

Started by vmfyelloq19, March 29, 2022, 11:33:10 AM

Previous topic - Next topic

vmfyelloq19

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.


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

vmfyelloq19

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.