Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

translate question
 
hogehoge
Jr. Member
 
Total Posts:  10
Joined:  2008-05-06
 

How to change the locale, please tell me.

My code:

/**
* Payment expired. 
*
* This method operates by cron.
*/
public function bankpaymentExpired($schedule)
{
    $orderIds 
= array('200000010''100000011');// Provisional

    
$currentLocale Mage::app()->getLocale()->getLocaleCode();

    foreach (
$orderIds as $orderId{
        $order 
Mage::getModel('sales/order')->loadByIncrementId($orderId);
        if (
$order->getId()) {
            
if (!$order->canCancel()) {
                
// uneditable order
            
}
            
elseif ($order->hasInvoices()) {
                $invoices 
$order->getInvoiceCollection();
                foreach (
$invoices as $invoice{
                    
if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID{
                        
// uneditable order
                    
}
                }
            }
            
else {
                
// get locale
                
$orderLocale Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE$order->getStoreId());
                
//change locale
                
Mage::app()->getLocale()->setDefaultLocale($orderLocale)->setLocale($orderLocale);
                
                
                
// This text is not appropriately translated though the locale was changed. 
                // It always becomes set of default. 
                
$comment Mage::helper('mymodule')->__("Your payment has expired.");
                
                
                
Mage::app()->getLocale()->setDefaultLocale($currentLocale)->setLocale($currentLocale);

                
$order->cancel()->save();
                
                
$order->setCustomerNote($comment)
                            ->
setCustomerNoteNotify(true)
                            ->
addStatusToHistory(
                                
$order->getState(),
                                
$order->getCustomerNote(),
                                
$order->getCustomerNoteNotify()
                            )
                            ->
sendOrderUpdateEmail($order->getCustomerNoteNotify(), $order->getCustomerNote())
                            ->
save();
                
            
}
        }
        
else {
            
// order not found.
        
}
    }
}

*The csv file is set up.

Someone please tell me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nabuhonodozor
Member
 
Avatar
Total Posts:  51
Joined:  2008-03-27
 

Hi
Could You be more specific.
Do You mean showing correct caption for
__("Your payment has expired.");
Or else?
Best regards,
Piotr

 
Magento Community Magento Community
Magento Community
Magento Community
 
hogehoge
Jr. Member
 
Total Posts:  10
Joined:  2008-05-06
 

Sorry.
I meant that I’d like to have __("Your payment has expired."); shown in line with the locale code for an placed order.

Thanks for your reply.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

did you save the csv (f.e. if you use german umlauts) in UTF8? Code seems to be correct.

Cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
hogehoge
Jr. Member
 
Total Posts:  10
Joined:  2008-05-06
 

Yes, I saved the csv in UTF8.

I set up the following two files.
app/locale/en_US/Mycompany_Payment.csv
app/locale/ja_JP/Mycompany_Payment.csv

However, it always becomes the text of ja_JP($currentLocale).

Hmm

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

could you please post the content of app/locale/en_US/Mycompany_Payment.csv
or only the relevant snippet?

cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
hogehoge
Jr. Member
 
Total Posts:  10
Joined:  2008-05-06
 

It solved it. wink

$orderLocale Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE$order->getStoreId());
Mage::app()->getLocale()->setDefaultLocale($orderLocale)->setLocale($orderLocale);
$translate Mage::getModel('core/translate');
$translate->init('frontend');
$comment $translate->translate(array(new Mage_Core_Model_Translate_Expr("Your payment has expired."'mymodule')));
Mage::app()->getLocale()->setDefaultLocale($currentLocale)->setLocale($currentLocale);

However, it is not a smart code ・・・. shut eye

For the time being in the solution.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top