This plugin provides convenient features for generating translations in your Flutter project using the l18n (localization) package. It integrates with IntelliJ IDEA and offers the following features:
-
Intention Action: While editing a Dart String literal, you can press
Alt+Enter
and select "Generate Translations" from the menu. This action generates the translation for the selected string. -
Translate File Action: You can right-click on an
.arb
(Application Resource Bundle) file in the project view and choose the "Translate this to new Arb file" option. This action translates the entire file.
To use this plugin, you need an OpenAI API key. Please make sure you have the API key before proceeding.
Here are some ideas, if you want to improve (sorry for the code base)
Currently, we can only provide simple translations. It would be nice to have support for placeholders, e.g. "Hello, {name}!". - I tried to work a little bit with gpt-3.5 here. It’s theoretically possible, but the output is not yet "good enough", and you will do it yourself then.
-
read untranslated keys (from flutter l10n file)
-
get keys (key + @key) from base
-
translate keys
-
append to file
-
unscramble file
-
reformat file
often times you have identical structure, and you want to see the latest one
This plugin was developed for the purpose of learning Kotlin and IntelliJ IDEA plugin development. The code quality may not be optimal as it was developed while experimenting with Domain-Driven Design (DDD) and faced time constraints.
Please note that this plugin is provided as-is, and I do not guarantee its compatibility with future versions of Flutter or IntelliJ IDEA. Use it at your own risk.
If you encounter any issues or have suggestions for improvement, feel free to report them on the project’s GitHub repository.
Important: Keep in mind that the use of the OpenAI API for translation may be subject to terms and conditions, including limitations on the number of requests or usage restrictions. Ensure you comply with OpenAI’s guidelines and any applicable usage restrictions when using this plugin.
We hope you find this plugin helpful for your Flutter localization needs!