Download the extension from the Visual Studio Marketplace or the Open VSX Registry

Features
This extension adds a single code action :
Extract selected text, prompt for a key or infer from text, update ARB files with DeepL translations, generate dart code, and replace hardcoded strings with the generated key.
Quick Setup
You should already have a l10n.yaml file in your project. If not, create one.
it uses flutter's official options for internationalization. see here
This extension extends existing options with the following options:
Options with default values
# l10n.yaml (extension specific options)
# Enable translation
translate: true
# Auto run flutter gen-l10n
generate : true
# Key prefix for translation
key-prefix: AppLocalizations.of(context)!.
# Generate key name
# "ask" : prompt with pre-filled text | true : infer from text | false : prompt
auto-name-key: true
# Language to use for key name
key-name-language: en
# Import line if needed
import-line: ""
For the translation feature to work, you need to add your Deepl API key in vscode settings.json file:
"flutter.deeplApiKey": "your-key",
You can get a free one here
And that's it! You're ready to go 🚀
Links
Download the extension from the Visual Studio Marketplace or the Open VSX Registry
If you want to add a feature or file a bug, please open an issue/PR on the GitHub repository
Pro tips
You can define an extension getter to access your translations more concisely:
extension ContextExt on BuildContext {
AppLocalizations get t => AppLocalizations.of(this);
}
// then instead of this
Text(AppLocalizations.of(context).yourKey)
// use it like this:
Text(context.t.yourKey)
Don't forget to update the key-prefix
& import-line
options in l10n.yaml ;)
Changelog
You can find it here
I try to follow Semantic Versioning:
- Major: Breaking changes
- Minor: New features, but backward-compatible
- Patch: Bug fixes
Support
If you'd like to support this project, consider contributing here. Thank you! :)