为什么主题translate.csv不能动态地为“我的购物车(%s)”工作?

时间:2011-12-30 02:20:13

标签: magento

我正试图通过"%s Items in Cart"将“我的购物车”翻译为/my_theme/locale/en_US/translate.csv

我有一个自定义购物车:

<?php $_cartQty = $this->getSummaryCount() ?>
<?php $cartText = (!empty($_cartQty)) ? $_cartQty : '0'; ?>
<li class="cart">
    <a href="<?php echo $this->getUrl('checkout/cart') ?>" class="cart-link"><?php echo $this->__('My Cart (' . $cartText . ')') ?></a>

以下所有工作正常:

"My Cart","0 Items in Cart"
"My Cart (0)","0 Items in Cart"
"My Cart (1)","1 Item in Cart"
"My Wishlist (%d items)","Wishlist (%d)"
"My Wishlist (%d item)","Wishlist (%d)"
"My Wishlist","Wishlist"

什么不起作用:

"My Cart (%s)","%s Items in Cart"
"My Cart (%d)","%d Items in Cart"

我是否忽略了一些荒谬的事情?

2 个答案:

答案 0 :(得分:3)

我认为你应该使用:

<?php echo $this->__('My Cart (%s)', $cartText) ?>

而不是:

<?php echo $this->__('My Cart (' . $cartText . ')') ?>

答案 1 :(得分:0)

尝试在translate.csv中使用(例如英语为德语):

"There are <a href=""%s"">%s items</a> in your cart.","Es sind <a href=""%s""><strong>%s Produkte</strong></a> in Ihrem Einkaufskorb."

"There is <a href=""%s"">1 item</a> in your cart.","Es ist <a href=""%s""><strong>1 Produkt</strong></a> in Ihrem Einkaufskorb."