国际化
TrendiKnow 通过 Crowdin 管理多语言资源。当前翻译源覆盖两类内容:服务端股票名称与客户端的 UI 字符串。
Crowdin 配置
仓库根目录的 crowdin.yml 定义了上传 / 下载规则:
yaml
project_id: "trendiknow"
api_token_env: CROWDIN_PERSONAL_TOKEN
files:
# 服务端:股票名称翻译
- source: "/trendiknow-server/data/json/stock_name/en.json"
translation: "/trendiknow-server/data/json/stock_name/%locale%.json"
type: "json"
# 客户端:UI 字符串翻译
- source: "/trendiknow-uniclient/assets/i18n/en.json"
translation: "/trendiknow-uniclient/assets/i18n/%locale%.json"
type: "json"source为英文源文件,translation中的%locale%会被目标语言代码替换(如zh-CN.json)。api_token_env指向环境变量CROWDIN_PERSONAL_TOKEN,避免把 token 写进仓库。
常用命令
bash
# 上传源文件到 Crowdin
crowdin upload sources
# 下载翻译回仓库
crowdin download客户端多语言
客户端 lib/i18n/ 与 assets/i18n/ 负责运行时语言切换(locale_service.dart)。新增 UI 文案时,先更新 assets/i18n/en.json,再由 Crowdin 分发到其他语言。
服务端股票名称
服务端 data/json/stock_name/en.json 维护股票代码到英文名的映射;其他语言(如中文)由 Crowdin 生成对应 xx.json,客户端展示时按当前语言读取。
