How to debug multiple translations in Magento?
When your store is dealing with multiple translations, sometimes you just want to see a list of which translations are coming from what modules. Magento doesn’t offer a way to get this information without editing the core, so what I am about to do should only be done for debugging and then removed.
First, located:
This will, for every request, write a bunch of lines to the translate.log file under /var/log.
The file will looks something like:
After you figure out which module is displaying the translation, remove the lines of code from Mage_Core_Model_Translate and be on your merry way!
When your store is dealing with multiple translations, sometimes you just want to see a list of which translations are coming from what modules. Magento doesn’t offer a way to get this information without editing the core, so what I am about to do should only be done for debugging and then removed.
First, located:
- File: app/code/core/Mage/Core/Model/Translate.php
- Class: Mage_Core_Model_Translate
- Function: translate()
$logModule = str_pad($module, 25, "-", STR_PAD_RIGHT);
$logInString = str_pad($text, 150, "-", STR_PAD_RIGHT);
$logOutString = str_pad($result, 200, " ", STR_PAD_RIGHT);
Mage::log($logModule . '>' . $logInString . '>' . $logOutString, null, 'translate.log');
This will, for every request, write a bunch of lines to the translate.log file under /var/log.
The file will looks something like:
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Qty--------------------------------------------------------------------------------------------------------------------------------------------------->Qty
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->OR---------------------------------------------------------------------------------------------------------------------------------------------------->OR
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Add to Wishlist--------------------------------------------------------------------------------------------------------------------------------------->Add to Wishlist
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Add to Compare---------------------------------------------------------------------------------------------------------------------------------------->Add to Compare
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Quick Overview---------------------------------------------------------------------------------------------------------------------------------------->Quick Overview
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Details----------------------------------------------------------------------------------------------------------------------------------------------->Details
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Tag----------------->Product Tags------------------------------------------------------------------------------------------------------------------------------------------>Product Tags
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Tag----------------->Add Your Tags:---------------------------------------------------------------------------------------------------------------------------------------->Add Your Tags:
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Tag----------------->Add Tags---------------------------------------------------------------------------------------------------------------------------------------------->Add Tags
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Tag----------------->Add Tags---------------------------------------------------------------------------------------------------------------------------------------------->Add Tags
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Tag----------------->Use spaces to separate tags. Use single quotes (') for phrases.--------------------------------------------------------------------------------------->Use spaces to separate tags. Use single quotes (') for phrases.
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Checkout------------>My Cart----------------------------------------------------------------------------------------------------------------------------------------------->My Cart
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Checkout------------>You have no items in your shopping cart.-------------------------------------------------------------------------------------------------------------->You have no items in your shopping cart.
2011-03-14T18:55:25+00:00 DEBUG (7): Mage_Catalog------------->Compare Products-------------------------------------------------------------------------------------------------------------------------------------->
After you figure out which module is displaying the translation, remove the lines of code from Mage_Core_Model_Translate and be on your merry way!
No comments:
Post a Comment