Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>auto-text-gen-reactNew to Visual Studio Code? Get it now.
auto-text-gen-react

auto-text-gen-react

hyminghan

|
45 installs
| (0) | Free
自动提取 JSX 文案并生成 key/value 写入指定 json 文件
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

auto-text-gen-react README

自动提取 JSX 文案并生成 key/value 写入指定 json 文件

使用

在 .vscode/settings.json 中配置

{
  "autoTextGenReact.textFilePath": "locales/en.json", // 文案文件路径,提取后将写入该文件,必须使用相对路径
  "autoTextGenReact.keyLeftChar": "", // 提取文案后替换原有文案key左侧自定义字符
  "autoTextGenReact.keyRightChar": "" // 提取文案后替换原有文案key右侧自定义字符
}

在代码中选择 jsx/tsx 代码右键即可看到【提取 JSX 文本】选项,也可以 (Mac command/Windows ctrl) + shift + p,输入 >提取 即可看到【提取 JSX 文本】,注意,选择 jsx/tsx 代码时必须首位符合规范,例如:

// ✅
<div>
  hello
  <span>world</span>
</div>
// ❌
  hello
  <span>world</span>
</di

必须有个父节点,实在不知怎么选,直接全选整个文件即可,只要代码没有错误,能通过 Babel 就能行

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