Codegento Who Let Mage Out Of The Cage?

15Mar/110

Debugging Translations

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()

Then, right before the line "return $result;", put the following snippet of code:

$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-------------------------------------------------------------------------------------------------------------------------------------->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!

Posted by Ben Robie

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

Trackbacks are disabled.