You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopify区块设置中使用本地化翻译遇阻,求解决方案

Shopify区块Schema本地化翻译报错解决方案

问题根源

你误用了翻译路径的命名空间——区块的本地化词条不属于sections命名空间,而是blocks命名空间,所以sections.slideshow.title会找不到对应翻译。另外,Schema的JSON配置里不能直接写Liquid标签(比如{{ 'sections.eg-logo-carousel.direction' | t }}),必须用Shopify规定的t:[路径]格式引用翻译。

正确配置方式

假设你的区块handle是slideshow(即区块文件名为slideshow.liquid),按以下步骤调整:

  1. 保留区块内的locales定义(结构无需修改):
"locales": {
    "en": {
        "title": "Slideshow"
    },
    "fr": {
        "title": "Diaporama"
    }
}
  1. 修正Schema中的翻译引用路径:
    将原来的"t:sections.slideshow.title"替换为"t:blocks.slideshow.title",示例:
{
    "type": "header",
    "content": "t:blocks.slideshow.title"
}
  1. 区块模板内的翻译调用优化:
    在区块的Liquid模板中调用翻译时,除了完整路径写法{{ 'blocks.slideshow.title' | t }},也可以用相对路径简化:
{{ 'title' | t: scope: 'blocks.slideshow' }}

关键注意事项

  • 如果你的区块是独立可复用区块(而非嵌套在某section的blocks数组中),务必保证翻译路径的前缀是blocks.[区块handle],和区块文件名完全一致(比如文件是eg-logo-carousel.liquid,路径就是blocks.eg-logo-carousel.direction)。
  • Schema是JSON格式,不支持解析Liquid标签,必须使用t:前缀的格式引用翻译,否则会原样输出字符串。

内容的提问来源于stack exchange,提问作者Engin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 08:52:36