I'm new to Magento and I've just built a custom module for a store. The module observes the event sales_order_place_before, and checks with an outside source if an item is still in stock. When the customer wants to pay for the order and a product in the cart is out of stock, I throw an error in my Observer.php model. It appears as a popup for the customer.

    Mage::throwException("item not in stock");

Is it possible to throw this error in multiple languages, for example English and Dutch? And how does that work? I can't seem to make sense of how to use translations in an observer instead of frontend. And since this is just a custom string, it could be anything, I would not be overwriting any Magento error.

EDIT: My module's config xml (I've removed the actual namespace and module name). Do I define a helper like this? What do I put in the helper?




I have created a helper with an empty class in Helper/Data.php in my module:

class Namespace_Modulename_Helper_Data extends Mage_Core_Helper_Abstract{}

I've added the csv file in app/locale/nl_NL

  • 1
    You should call your module's helper to provide the translation: Mage::throwException(Mage::helper('custom_module')->__("item not in stock")); If you would provide your custom module's config.xml in your question then we could specify this solution more.
    – 7ochem
    Nov 4, 2015 at 10:14

2 Answers 2


Please try this but not sure

               Mage::throwException($this->__("item not in stock"));    //or
               Mage::throwException(Mage::helper('core')->__("item not in stock"));


Try this

   Mage::throwException(Mage::helper('core')->__("item not in stock"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.