2011-08-25 85 views

回答

5

这应该工作:

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

谢谢,似乎是工作(没有错误),但它没有,如果我翻译把一个翻译放在'translate.csv'文件中。我如何告诉它使用哪种语言?我希望它使用'sv_SE'。 –

+0

我添加了一行新的代码来强制Magento翻译器以sv_SE语言工作。不知道它是否有效,但完成任务的最佳方式是为每种语言创建不同的商店视图:http://www.magentocommerce.com/design_guide/articles/magento-design-terminologies4 –

+0

非常感谢! –

8

我想设置的地点正确的方法是:

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

如果你复制并粘贴这段代码,这将会在不使用缓存的情况下检索事务,正确的方法是:'Mage :: getSingleton('core/translate') - > setLocale('sv_SE') - > init('frontend ');'你被警告! –