我创建了一个模块,当客户选择特定的付款类型时,该模块会发送带有pdf附件的电子邮件。您可以在后端重新发送带有附件的电子邮件。自动发送的pdf将以正确的商店默认语言进行翻译。但是,当我用pdf手动重新发送电子邮件时,我不知道如何更改pdf的翻译语言。
我可以更改用于以下用途的电子邮件模板:
$local = Mage::getStoreConfig('general/locale/code', $storeId)
$emailTemplate->loadDefault('my_email_template', $local);
我试图更改本地代码:
Mage::app()->getLocale()->setLocaleCode($local);
本地代码已更改,但未将其翻译为正确的语言。如何设置必须翻译成哪种语言?
谢谢!
尝试商店视图仿真。
您可以将需要包装的代码通过仿真包装成另一种语言。它看起来像这样:
$enulatedStore = Mage::getSingleton('core/app_emulation');
$inivitalEnvSettings = $emulatedStore->startEnvironmentEmulation($storeId);
//here goes your code. It's going to be run as if it was your store view
$emulatedStore->stopEnvironmentEmulation($inivitalEnvSettings);
仿真意味着您需要暂时切换商店视图。Magento将加载其所有设置,配置和设计等。这非常方便,尤其是当您要在admin中渲染前端页面时。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句