跳到正文
cccskills
免费在 GitHub 公开

go-i18n

Use when defining or updating Go CLI i18n rules in this repo, especially around locale files, env-based language selection, and key naming.

中文简介正在准备中。当前显示原文说明。

实测评分 未实测

查看安装方法

包含的文件(3)

  • SKILL.md2.8 KB
  • LICENSE.txt1.0 KB
  • README.md512 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Go CLI i18n

Overview

This skill documents the Go CLI i18n rules used in this repo, including language detection, locale files, and key naming conventions.

When to Use

  • You add or edit any user-facing CLI string in cmd/skills-x
  • You need to add a new skill description for list output
  • You are troubleshooting mixed language output or missing translations

Architecture Snapshot

  • i18n runtime: cmd/skills-x/i18n/i18n.go
  • Locale files: cmd/skills-x/i18n/locales/zh.yaml, cmd/skills-x/i18n/locales/en.yaml
  • Embed: //go:embed locales/*.yaml (locales are embedded at build time)

Language Selection

Priority order in detectLanguage():

  1. SKILLS_LANG
  2. LANG
  3. LC_ALL
  4. Default: zh

Normalization uses prefix matching:

  • zh, zh_CN, zh_TW → zh
  • en, en_US → en
  • Unsupported → zh

Using i18n in Go

Initialize once (early in main):

import "github.com/castle-x/skills-x/cmd/skills-x/i18n"

i18n.MustInit()

Translate strings:

title := i18n.T("list_header")
msg := i18n.Tf("init_success", skillName)

Missing keys return the key itself (useful for spotting gaps).

Key Naming Conventions

Use lowercase + underscores with category prefixes:

  • app_ app metadata
  • cmd_ command descriptions/flags
  • list_ list output
  • init_ init output
  • err_ error messages
  • cat_ category names
  • skill_ skill descriptions
  • meta_ meta warnings

Rule: Never mix Chinese and English in the same string. Use two locale keys instead.

Adding New Strings

  1. Add the same key to both locale files:
    • cmd/skills-x/i18n/locales/zh.yaml
    • cmd/skills-x/i18n/locales/en.yaml
  2. Use i18n.T / i18n.Tf in Go code.
  3. Rebuild (make build) to embed the updated YAML.
  4. Test:
    • SKILLS_LANG=zh ./bin/skills-x list
    • SKILLS_LANG=en ./bin/skills-x list

New Skill Description

Add a skill_<skill-name> key to both locale files. The list view reads descriptions from i18n, not from the skill file.

Example

# locales/en.yaml
init_success: "Installed: %s"

# locales/zh.yaml
init_success: "安装成功: %s"
fmt.Println(i18n.Tf("init_success", skillName))

Quick Reference

ItemValue
Locale filescmd/skills-x/i18n/locales/{zh,en}.yaml
Initi18n.MustInit()
Translatei18n.T, i18n.Tf
Language prioritySKILLS_LANG > LANG > LC_ALL > zh

Common Mistakes

  • Only adding a key in one locale file
  • Hardcoding mixed-language strings
  • Forgetting to rebuild after YAML changes
  • Formatting with fmt.Sprintf before calling i18n.Tf

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

百度语音识别 - 将语音消息转换为文本。支持中文普通话、英语、粤语、四川话。专为国内服务器环境优化,自动绕过代理访问百度 API。

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

Use when you have a written implementation plan to execute in a separate session with review checkpoints

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

帮助用户将飞书群机器人 Webhook 通知接入 Claude Code,使得每次任务完成后自动发送飞书消息卡片通知。 触发场景(当用户提到以下任意内容时激活此 skill): - "飞书通知"、"接入飞书"、"飞书提醒" - "task 完成通知"、"任务完成提醒" - "claude 完成提醒"、"claude 通知" - "Stop hook 通知"、"hook 通知" - "发飞书消息"、"飞书机器人" - "任务结束通知"、"配置通知"

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

中文简介正在准备中。当前显示原文说明。

castle-x/skills-x182026年4月16日 更新

查看 castle-x 的全部技能

报告此技能的问题