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

如何为Crowdin CLI指定翻译文件的输出路径?

Crowdin CLI 配置:扁平源文件下载到本地层级路径

问题场景

  • 需求:将Crowdin平台上扁平结构的文件(如/file.ext)下载到本地指定层级路径(如/folder/folder2/file.ext)
  • 当前可正常实现扁平转扁平的配置:
"preserve_hierarchy": true

files: [
 {
  "source" : "/**/*.*",
  "translation" : "/%locale%/%original_file_name%"
 },
 {
  "source" : "/**/*.*",
  "translation" : "/%two_letters_code%/%original_file_name%"
 }
]
  • 修改translation为/folder/folder2/file.ext后出现报错:

Downloaded translations don't match the current project configuration.
The translations for the following sources will be omitted (...)

解决方案

报错原因是配置未包含locale变量(Crowdin需要通过locale区分不同语言的翻译文件),且层级匹配逻辑冲突。按以下配置修改即可实现需求:

preserve_hierarchy: false

files: [
  {
    "source": "/*.*",
    "translation": "/folder/folder2/%locale%/%original_file_name%"
  },
  {
    "source": "/*.*",
    "translation": "/folder/folder2/%two_letters_code%/%original_file_name%"
  }
]

关键配置说明

  • preserve_hierarchy: false:源文件是扁平结构,关闭层级保留可避免Crowdin尝试匹配不存在的子目录结构
  • source: "/*.*":精准匹配Crowdin平台根目录下的所有扁平文件(原/**/*.*会递归匹配子目录,不符合你的源文件结构)
  • translation路径:将固定本地层级/folder/folder2/前置,同时保留%locale%或%two_letters_code%变量,确保每个语言的翻译文件被正确归类到指定层级下,符合Crowdin的配置规则

补充说明

直接写死/folder/folder2/file.ext会导致Crowdin无法区分不同语言的翻译文件——平台上的翻译文件是按语言组织的,必须在translation路径中包含locale相关变量,否则会出现配置不匹配的报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 09:54:17