Niklas Modess
Niklas Modess

Reputation: 2539

Magento translations in external script

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.

Upvotes: 5

Views: 5635

Answers (2)

cads
cads

Reputation: 171

I think the right way to set locale is:

Mage::getSingleton('core/translate')->setLocale('sv_SE')->init('frontend', true);

Upvotes: 10

Fabrizio D'Ammassa
Fabrizio D'Ammassa

Reputation: 4769

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

Upvotes: 6

Related Questions