A Visual Studio Code extension that simplifies the internationalization workflow for Flutter applications by extracting strings to ARB files.
Features
- Quick String Extraction: Select text in your Dart files and extract it to ARB files with a single command
- Smart Key Generation: Automatically suggests appropriate keys based on the selected text
- Variable Detection: Automatically detects variables in your strings and configures them as placeholders in ARB
- Type Inference: Intelligently infers Dart types for variables in your strings
- Code Replacement: Automatically replaces the selected text with the appropriate localization code
- Context Menu Integration: Access the extraction feature directly from the editor context menu
Installation
- Open VS Code
- Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X on macOS)
- Search for "Flutter ARB Extractor"
- Click Install
Usage
- Select a string in your Dart file that you want to internationalize
- Right-click and select "Extract to ARB" from the context menu, or:
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS) and run "Extract Text to ARB"
- Select the target ARB file from the dropdown
- Enter a key name for the string (a suggestion will be provided)
- Optionally add a description for translators
- The string will be added to the ARB file and replaced with the appropriate localization code in your Dart file
Example
Before:
Text('Hello, ${username}!')
After extraction:
Text(context.l10n.hello(username))
And in your ARB file:
{
"hello": "Hello, {username}!",
"@hello": {
"description": "Greeting message with username",
"placeholders": {
"username": {
"type": "String"
}
}
}
}
Requirements
- Visual Studio Code 1.103.0 or higher
- Flutter project with ARB files for internationalization
Extension Settings
Configure the extension to match your project’s style and workflow:
flutterArbExtractor.l10nAccessor : Expression used to access localization strings (e.g. context.l10n or S.of(context) ). Default: context.l10n
flutterArbExtractor.keyCase : Naming style to use when generating ARB keys. Options: snake_case , camelCase , or PascalCase . Default: snake_case
flutterArbExtractor.promptForDescription : Whether to prompt for description when extracting text. Default: true
Known Issues
None at this time.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This extension is licensed under the MIT License.
Copyright (c) 2025 Rexford Asamoah
| |