fix(i18n): restore locale validation on Windows #304
Loading…
Reference in New Issue
No description provided.
Delete Branch "muel/gitlink-cli:fix/i18n-locale-eol"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
本 PR 修复当前最新
master上 i18n 本地校验在 Windows 环境下容易失败的问题。主要修复在开发时发现的两类失败:
.gitattributes固定 locale JSON 为 LF,修复go run ./internal/i18n/cmd/check的格式校验失败。cmd.ignore.short,修复go run ./internal/i18n/cmd/check --scan-code的缺 key 失败。问题现象
1.
check格式校验失败在 Windows 环境下执行:
报错:
该问题是 Windows 工作区行尾可能被检出为 CRLF,导致 i18n check 工具与 Go JSON formatter 输出的 LF 格式发生字节级差异。
2.
--scan-code缺少 locale key执行:
报错:
当前
shortcuts/register.go已引用:但
internal/i18n/locales/en-US.json和internal/i18n/locales/zh-CN.json中缺少对应 key,因此 scan-code 会失败。修复内容
1. 固定 i18n locale JSON 的行尾格式
新增
.gitattributes:作用:
.gitattributes自身使用 LF。internal/i18n/locales/*.json使用 LF。core.autocrlf=true时将 locale JSON 检出为 CRLF。go run ./internal/i18n/cmd/check在 Windows / Linux / macOS 下格式判断一致。2. 补充缺失的
cmd.ignore.shortlocale key英文 locale 新增:
中文 locale 新增:
用于匹配当前代码中的:
从而修复:
中的缺 key 报错。
修改范围
本 PR 仅修改:
当前情况
1.
.gitattributes修复 check 格式失败修复前:
会在 Windows 环境下报:
修复后,通过
.gitattributes固定 locale JSON 为 LF,避免 CRLF 与 formatter LF 输出不一致导致的格式失败。2. 补充
cmd.ignore.short修复 scan-code 缺 key 失败修复前:
会报:
修复后,
en-US.json和zh-CN.json都补充了cmd.ignore.short,与shortcuts/register.go中的引用保持一致。验证结果
本地已执行并通过:
说明
这个问题不是翻译 key schema 设计问题,也不是 locale JSON 内容损坏。
实际包含两个独立原因:
cmd.ignore.short,但两个 locale JSON 中没有补齐该 key。本 PR 分别通过
.gitattributes固定行尾格式,以及补充缺失 locale key,使 i18n 校验在 Windows / Linux / macOS 下保持一致。Pull request closed