Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Chinese KeywordNew to Visual Studio Code? Get it now.
Chinese Keyword

Chinese Keyword

alwaysingle

|
2 installs
| (0) | Free
将主流编程语言关键字显示为中文的装饰器,如把if显示为如果,不会对代码产生任何影响
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Chinese Keyword Decorator

一个VSCode扩展,将编程语言关键字显示为中文装饰器,支持多种语言和自定义配置。

功能特性

  • 🎨 在关键字后面显示对应的中文翻译
  • 🌐 默认支持JavaScript、TypeScript、Vue、Java文件,可手动修改配置
  • 🎯 支持文件后缀过滤,关键字只在指定文件类型中生效
  • ⚙️ 丰富的自定义配置选项
  • 🔄 实时更新装饰器,支持防抖优化
  • 🚫 支持关键字排除功能
  • 📦 内置常用包路径和注解支持

使用方法

扩展激活后会自动在关键字后面显示中文翻译,例如:

JavaScript/TypeScript

  • function → 函数
  • const → 常量
  • async → 异步
  • console.log → 控制台打印

Java

  • class → 类
  • public → 公开
  • String → 字符串
  • System.out.println → 控制台打印
  • @Override → 重写

配置选项

1. 自定义关键字映射

支持两种配置格式:

"chineseKeywordDecorator.customKeywords": {
  // 简字符串格式
  "if": "如果",
  
  // 完整对象格式
  "for": {
    "text": "循环",
    "color": "#ff6b6b",
    "fileSuffix": "java,class"
  }
}

参数说明:

  • text: 中文翻译(必填)
  • color: 自定义颜色(可选,默认使用 defaultColor)
  • fileSuffix: 文件后缀,多个后缀用逗号分隔(可选,默认支持所有文件),注意,java文件后缀肯是编译后的 class

2. 支持的文件类型

"chineseKeywordDecorator.supportedLanguages": [
  "javascript",
  "typescript", 
  "vue",
  "java"
]

3. 排除关键字

如果你不想装饰某些关键字,可以将它们添加到排除列表:

"chineseKeywordDecorator.excludedKeywords": [
  "if",
  "else",
  "for"
]

4. 其他配置

{
  // 是否显示原始关键字
  "chineseKeywordDecorator.showOriginalKeyword": false,
  
  // 默认翻译颜色
  "chineseKeywordDecorator.defaultColor": "#cc99cd",
  
  // 正则表达式前缀(用于匹配关键字前的模式)
  "chineseKeywordDecorator.regexPrefix": "(?<=^|\\s)",
  
  // 正则表达式后缀(用于匹配关键字后的模式)
  "chineseKeywordDecorator.regexSuffix": "(?![\\w'\":\\-=])"
}

内置关键字

JavaScript/TypeScript 关键字

包含所有常用的JS/TS关键字,如:function、const、let、class、async、await、export、import 等。

Java 关键字

包含Java基础关键字、数据类型、修饰符等:

  • 基础关键字:class、public、private、static、final 等
  • 数据类型:int、String、boolean、double 等
  • 控制语句:if、for、while、switch 等

Java 注解支持

内置常用的Java注解:

  • 标准注解:@Override、@Deprecated、@SuppressWarnings 等
  • 元注解:@Retention、@Target、@Inherited 等

常用包路径

内置Java常用包路径的翻译:

  • 标准库:java.lang、java.util、java.io 等
  • Spring框架:org.springframework、org.springframework.boot 等
  • 第三方库:com.google.gson、org.apache.commons 等

交互功能

  • 点击装饰器:临时禁用当前装饰器的显示
  • 重置命令:通过命令面板执行 Chinese Keyword Decorator: Reset 来重置所有装饰器

安装和使用

  1. 在VSCode扩展市场搜索 "Chinese Keyword Decorator"
  2. 点击安装
  3. 重新加载VSCode
  4. 扩展会自动激活并开始装饰关键字

配置示例

完整配置示例

{
  "chineseKeywordDecorator.supportedLanguages": ["javascript", "typescript", "java"],
  "chineseKeywordDecorator.showOriginalKeyword": true,
  "chineseKeywordDecorator.defaultColor": "#cc99cd",
  "chineseKeywordDecorator.excludedKeywords": ["debugger"],
  "chineseKeywordDecorator.customKeywords": {
    "customFunction": {
      "text": "自定义函数",
      "color": "#e74c3c",
      "fileSuffix": "js,ts"
    }
  }
}

许可证

MIT License

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft