Add i18n locale

From GXFG/newtab-naivetab · View interactive version

Add i18n locale is an AI agent skill from the GitHub repository GXFG/newtab-naivetab. NaiveTab 浏览器扩展的 i18n 国际化开发指南。当用户要新增/修改翻译文本、添加多语言 key 时使用。涵盖中英文同步更新规则、变量替换模式等,防止遗漏或格式错误。

How to use this skill

Skill file

NaiveTab Add i18n Locale

新增或修改 i18n 翻译文本需遵守以下规则。

文件位置

两个文件必须同步更新,不能只改一个。

Key 命名规范

采用扁平嵌套结构,按功能分组:

{
  "common": {
    "save": "保存",
    "cancel": "取消"
  },
  "setting": {
    "group": {
      "myPane": "我的面板"
    }
  }
}

引用方式:window.$t('common.save') 或模板中 $t('setting.group.myPane')。

变量替换

使用 __key__ 占位符 + .replace() 方式,禁止使用 vue-i18n 默认的 {key} 语法:

<!-- 正确 -->
{{ $t('key.xxx').replace('__n__', value) }}

<!-- 错误 -->
{{ $t('key.xxx', { n: value }) }}
// 正确
window.$t('key.xxx').replace('__count__', String(count))

覆盖范围

所有面向用户的文本都必须 i18n,包括但不限于:

注意事项

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.