Pierre
Pierre

Reputation: 135

Email translation issue in Magento 1.9

I've got a problem with a translation. I don't understand why my content is well translated in the website but not in the email. The translation is done in csv files, but when I call the sentence, as usual, Magento got the english translation instead of the french one.

email/stock.phtml :

    <?php if ($products = $this->getProducts()): ?>
<p><?php echo $this->__('You are receiving this notification because you subscribed to receive alerts when the following products are back in stock:') ?></p>
<table>
<?php foreach ($products as $product): ?>
    <tr>
        <td><a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(75, 75) ?>" border="0" align="left" height="75" width="75" alt="<?php echo $this->escapeHtml($product->getName()) ?>" /></a></td>
        <td>
            <p><a href="<?php echo $product->getProductUrl() ?>"><strong><?php echo $this->escapeHtml($product->getName()) ?></strong></a></p>
            <?php $shortDescription = $this->_getFilteredProductShortDescription($product) ?>
            <?php if ($shortDescription): ?>
                <p><small><?php echo $shortDescription ?></small></p>
            <?php endif; ?>
            <p><?php if ($product->getPrice() != $product->getFinalPrice()): ?>
                <?php echo $this->__('Regular Price:') ?> <strong style="text-decoration:line-through;"><?php echo Mage::helper('core')->currency($product->getPrice()) ?></strong><br />
                <strong><?php echo $this->__('Special price:') ?> <span style="color:#FF0000;"><?php echo Mage::helper('core')->currency($product->getFinalPrice()) ?></span></strong>
            <?php else: ?>
                <strong><?php echo $this->__('Price:') ?></strong> <?php echo Mage::helper('core')->currency($product->getPrice()) ?>
            <?php endif; ?></p>
            <p><small><a href="<?php echo $this->getProductUnsubscribeUrl($product->getId()) ?>"><?php echo $this->__('Click here not to receive alerts for this product') ?></a></small></p>
        </td>
    </tr>
<?php endforeach; ?>
</table>
<p><a href="<?php echo $this->getUnsubscribeUrl() ?>"><?php echo $this->__('Unsubscribe from all stock alerts') ?></a></p>
<?php endif; ?>

Do you know how to say to Magento that it has to take the french translation in my email template ?

Upvotes: 3

Views: 903

Answers (2)

versedi
versedi

Reputation: 191

First of possibility: https://magento.stackexchange.com/questions/25612/cron-job-template-block-not-being-translated-but-testobserver-is

Second possibility:

Function that's responsible for sending product out of stock alert is called send and exists in file around line 229:

app/code/core/Mage/ProductAlert/Model/Email.php

The function's using below code to get customer's store:

$store = Mage::getModel('core/store')->load($this->_customer->getStoreId());

Function getStoreId on customer gets data from field "Created from - account[created_in]"

So if customer was created by an Admin from backend - the customer will always get default store (admin's) settings for language, currency, translations, etc.

Check what is returned for the customer that get's wrong translation and/or url's by this code:

<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {
   $customerData = Mage::getSingleton('customer/session')->getCustomer();
   echo $customerData->getStoreId();
} ?>

If it's 0 - that's the case.

Upvotes: 1

Deep Kakkar
Deep Kakkar

Reputation: 6305

To translate an email, you can copy it from the en_US folder to a corresponding language folder (es_ES, for example), then perform the translation. When you do this, you can also add or remove other vars from the email. Most emails will have headers that show you what vars are available.

As for adding a country code to the telephone number, you will need to define a new block in a module that will do this for you.

There is also another solution on link

Upvotes: 1

Related Questions