Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 601
Niklas Modess Avatar asked Aug 25 '11 10:08

Niklas Modess


2 Answers

I think the right way to set locale is:

Mage::getSingleton('core/translate')->setLocale('sv_SE')->init('frontend', true);
like image 160
cads Avatar answered Oct 20 '22 05:10

cads


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);
like image 27
Fabrizio D'Ammassa Avatar answered Oct 20 '22 06:10

Fabrizio D'Ammassa