外部脚本中的Magento翻译

Nik*_*ess 5 translation magento magento-1.5

我希望能够$this->__('String to translate')在外部脚本中使用.我该怎么做呢?Magento版1.5.1.0.

小智 9

我认为设置语言环境的正确方法是:

Mage::getSingleton('core/translate')->setLocale('sv_SE')->init('frontend', true);
Run Code Online (Sandbox Code Playgroud)


Fab*_*ssa 6

这应该工作:

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);
Run Code Online (Sandbox Code Playgroud)