0

how can I make this word "item(s)" translatable in the below code in line 20

        <td style="text-align:center">
            <ul>
                <?php
                $its = $giftbox->getItemCollection();
                $numberitems = 0;
                foreach ($its as $it) {
                    $itemId = $it->getItemId();
                    $item = Mage::getModel('sales/quote_item')->load($itemId);
                    $product = Mage::getModel('catalog/product')->load($item->getProductId());
                    $qty = $it->getQty();
                    $numberitems += $qty;
                    ?>
                    <!--loki-->
                    <?php
                    //$idProduct=Mage::getSingleton('core/session')->getIdProduct();
                    $classname = 'p' . $item->getProductId();
                    ?>
                    <li id="<?php echo $classname; ?>"><a href='<?php echo $product->getProductUrl(); ?>' ><?php echo $item->getName(); ?> </a><?php
                        if ($item->getProductId()) {
                            echo ' - ' . intval($qty) . ' item(s)';
                        }
                        ?> </li>
                    <!--end-->
                    <?php
                }
                if (Mage::getStoreConfig('giftwrap/calculation/amount_on_number_items')) {
                    $giftwrapAmount = floatval($numberitems) * (floatval($style->getPrice()) + floatval($giftcard->getPrice()));
                } else {
                    $giftwrapAmount = floatval($style->getPrice()) + floatval($giftcard->getPrice());
                }
                ?>
            </ul>
        </td>

1 Answer 1

1

wrap this word in inline translation function Mage::helper('core')->__()

echo ' - ' . intval($qty) . ' item(s)';

to

echo ' - ' . intval($qty) . ' ' . Mage::helper('core')->__('item(s)');

9
  • thank you very much. In which file I should put the translated word ?
    – mubdea
    Commented Apr 21, 2016 at 17:13
  • this did not work I got this error
    – mubdea
    Commented Apr 21, 2016 at 17:17
  • Parse error: syntax error, unexpected 'core' (T_STRING), expecting ',' or ';' in /home/edhel585/public_html/store/app/design/frontend/base/default/template/giftwrap/giftbox.phtml on line 313
    – mubdea
    Commented Apr 21, 2016 at 17:17
  • put line "item(s)","Translated item(s)" in app/design/frontend/default/default/locale/en_US/translate.csv where en_US is your locale
    – Ilja
    Commented Apr 21, 2016 at 17:18
  • ive fixed answer, check it out pls
    – Ilja
    Commented Apr 21, 2016 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.