https://github.com/7wilightxdev/flutter-localization-extractor
This Visual Studio Code extension simplifies the process of extracting and managing localization keys for Flutter applications
https://github.com/7wilightxdev/flutter-localization-extractor
flutter generator localization vscode-extension
Last synced: 2 months ago
JSON representation
This Visual Studio Code extension simplifies the process of extracting and managing localization keys for Flutter applications
- Host: GitHub
- URL: https://github.com/7wilightxdev/flutter-localization-extractor
- Owner: 7wilightxdev
- License: mit
- Created: 2024-12-25T04:05:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-01T04:29:35.000Z (9 months ago)
- Last Synced: 2025-10-01T06:25:06.747Z (9 months ago)
- Topics: flutter, generator, localization, vscode-extension
- Language: TypeScript
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Localization Key Extractor for Flutter
This Visual Studio Code extension simplifies the process of extracting and managing localization keys for Flutter applications. It allows developers to easily convert text into localized keys and manage ARB files (`app_en.arb`, `app_vi.arb`, etc.) directly from the editor.
## Features
- **Extract Localization Keys:** Quickly create localization keys from selected text.
- **Automatic ARB File Updates:** Add generated keys and translations directly to your ARB files.
- **Support for String Interpolation:** Handles placeholders like `$username` or `${username}` automatically.
- **Run Generate Command (Optional):** Automatically regenerate localization files after updates.
- **Customizable Configurations:** Define output files and prefixes via `extract_localization_config.yaml`.
## Installation
1. Install the extension from the Visual Studio Code Marketplace.
2. Add a `extract_localization_config.yaml` file to your project workspace (details in the **Configuration** section).
## Configuration
Add a `extract_localization_config.yaml` file to the root of your project with the following structure:
```yaml
outputFiles:
- lib/i10n/app_en.arb
- lib/i10n/app_vi.arb
prefix: AppLocalization.of(context)
genCommand: flutter gen-l10n
```
### Configuration Fields
1. `outputFiles`: A list of paths to your ARB files.
2. `prefix`: The prefix for localization calls (e.g., AppLocalization.of(context)).
3. `genCommand`: Whether to run gen command automatically.
## Usage
### 1. Generate Localization Key
1. **Select Text:** Highlight the text in your editor that you want to localize.
2. **Right-Click:** Choose **"Create Localization Key"** from the context menu.
3. **Fill the Prompt:**
- **Key Name:** Default is a camelCase version of the selected text.
- For interpolated strings, define placeholder types (e.g., `String`, `int`).
### 2. Automatic ARB File Updates
The generated key and its value will be added to all ARB files defined in your configuration. For example:
```json
{
"helloUsername": "Hello, {username}!",
"@helloUsername": {
"placeholders": {
"username": {
"type": "String"
}
}
}
}
```
### 3. Replace Selected Text
After generating the key, the selected text will be replaced with a localization call. For example:
#### Input
```dart
"Hello, $username!"
```
#### Output
```dart
AppLocalization.of(context).helloUsername(username)
```
### 4. Automatically Run Gen Command
If enabled in the `extract_localization_config.yaml`, the extension will automatically execute gen command after updating ARB files. This ensures your localization changes are immediately applied.
## License
This extension is licensed under the MIT License