2011-12-30 43 views
0

我试图通过/my_theme/locale/en_US/translate.csv将“我的购物车”翻译为"%s Items in Cart"为什么主题translate.csv无法为“我的购物车(%s)”动态工作?

我有一个自定义购物车:

<?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" 

我俯瞰什么可笑的?

回答

3

我认为你应该使用:

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

代替:

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

使用提供线Detzee。你可以看一下app/code/core/Mage/Checkout/Block/Links.php Magento如何处理默认顶部菜单链接中的0项/ 1项/ x项目。 – 2011-12-30 09:36:39

+0

啊,工作!十分感谢大家。 – 2011-12-30 21:45:31

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."