Extract Chinese strings from Flutter/Dart files, replace them with i18n accessors, and generate or update ARB files in one guided workflow.
Chinese version: README.zh-CN.md
Screenshots

Features
- Adds a context menu command for
*.dartfiles:Dart Chinese Extractor: Extract Chinese and Generate ARB - Parses Dart syntax with Web Tree-sitter to find string literals safely
- Detects Chinese text in plain strings and interpolated strings such as
$nameor${expr} - Shows a two-pane review panel with recognized strings on the left and key inputs on the right
- Prefills keys when an existing ARB entry already contains the same message
- Lets you clear all key inputs with confirmation
- Validates key format before writing changes
- Replaces source strings with accessors such as
S.of(context).title - Generates method-style accessor calls for interpolated strings, such as
S.of(context).hello(name) - Creates or updates ARB files, including
@key.placeholders
Usage
- Open a Flutter project in VS Code.
- Open a
*.dartfile. - Right-click in the editor and run
Dart Chinese Extractor: Extract Chinese and Generate ARB. - Review the detected Chinese strings on the left side of the panel.
- Enter one key per row on the right side.
- Click
Nextto replace the Dart source and update the ARB file.
Configuration
Add mine_chinese_extractor to the nearest Flutter package pubspec.yaml:
mine_chinese_extractor:
accessor_prefix: S.of(context).
arb_dir: lib/l10n
arb_file_name: intl_zh.arb
locale: zh
Options:
accessor_prefix: accessor prefix used in Dart replacements. Default:S.of(context).arb_dir: ARB directory relative to the nearestpubspec.yaml. Default:lib/l10narb_file_name: ARB file name. Default:intl_zh.arblocale: value written to@@localewhen the ARB file does not already define one. Default:zh
In monorepos, the extension searches upward from the current Dart file and uses the nearest pubspec.yaml. If no mine_chinese_extractor section is found, it continues with the defaults.
Generated Output
For a string like:
Text('你好,$name')
the extension can generate an ARB entry like:
{
"@@locale": "zh",
"helloName": "你好,{name}",
"@helloName": {
"placeholders": {
"name": {}
}
}
}
and replace the Dart code with:
Text(S.of(context).helloName(name))
Development
pnpm install
pnpm run build
pnpm run vsix