Flutter: internationalization tutorials: Part 3— Android Studio plugin

Let’s make internationalization in the easiest way

Thanh Dat Vo
2 min readSep 24, 2018

In the first and second parts, you may be exhausted with the implementation of translation with JSON and .arb. Well, not this time. We will continue to use .arb file but together with Android Studio plugin name flutter-i18n.

Which thing in the second approach makes you most tired? Is that you have to repeat run code in the terminal to generate code to .arb files and then translate, and then run code in the terminal to generate back to .dart files. What if the generation is done automatically and we only have to care about translation in .arb files. Well, flutter-i18n will help us do that. You can find this plugin here.

If we use this approach we do not need to use any libraries.

At first, install and turn on flutter-i18n in Android Studio.

When the plugin is turned on, it will generate res/value/string_en.arb and lib/generated/i18n.dart. The finished folder structure will be like this:

Let’s add some translations in strings_en.arb and strings_fr.arb:

You can see, in lib/generated/i18n.dart, a getter “hello” and a method greetTo were created:

Compared to the first 2 approaches, this approach is overwhelming, because:

  • You only need to concern to translation in .arb files
  • String formats (to number, to DateTime, …) are available

You can find the full source code here

If this approach does not satisfy you, you may want to try with JSON and .arb approaches in Part 1 and Part 2 respectively.

Hope you find this benefit you, and I’m happy to receive your feedback and some claps may make me proud too :D

Thanks for reading!

--

--