I want to be able to use $this->__('String to translate')
in an external script. How do I do this? Magento version 1.5.1.0
.
I think the right way to set locale is:
Mage::getSingleton('core/translate')->setLocale('sv_SE')->init('frontend', true);
This should work:
require 'app/Mage.php'; // here you should use the correct path to Mage.php file
Mage::app();
Mage::getSingleton('core/translate')->init('sv_SE', true); // UPDATE
$to_translate = "String to translate";
$translated = Mage::helper('core')->__($to_translate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With