如何在 prestashop 的 JSON 文件中添加语言翻译

How to add language translation in JSON file in prestashop

我使用 PS1.6,它使用两种语言。所以,要在 JSON 文件 "block-cart-json.tpl"

中完成这项工作

这种方式无效(添加到购物车弹出 window 未显示):

"condition": {if $product.condition|json_encode == 'used'}{l s='Used'}{elseif $product.condition|json_encode == 'new'}{l s='New'}{elseif $product.condition|json_encode == 'online'}{l s='Online'}{/if},

这样操作:

"condition": {$product.condition|json_encode}

但是如何解决我的多语言翻译问题?

如果您要修改 block-cart-json.tpl,您可能需要将 mod='blockcart' 添加到您的翻译中。

此外,我不确定您 {if} 的逻辑是否正确。将此逻辑放在 blockcart.php 中(您可以将其作为覆盖)并将已翻译的变量分配给您的 .tpl 文件会容易得多。

in blockcart.php in assignContentVars 方法类似于:

foreach ($products as &$product) {
    switch ($product['condition']) {
        case 'new':
            $product['product_condition'] = $this->l('New');
        break;

        case 'used':
            $product['product_condition'] = $this->l('Used');
        break;
    }
}