Nabil Mosharraf HossainWriting3D & Games

Extract all strings from dart to arb in Flutter

15 May 2021 · 2 min read
Originally published on Medium in May 2021. It was written in 2021, so library versions and APIs may have changed since; check current docs before copying code.
Photo by NeONBRAND on Unsplash

Flutter’s internationalisation is a solid approach to support localisation in the apps. However there is no easy way to extract strings from the dart codes into the arbs. The Flutter Intl plugin supports exporting strings using the IDE’s context menu but that is only available for single strings. So I created a code we can run to extract almost all strings from the codes.

nabil6391/flutter-strings-to-arb

Technical Details

What it does is that it searches for double and single qouted strings in a line and fetches the word/sentence in between.

Things you can do with the library code

Extract Strings to arb

Find all strings present in the codes

Skip Folders and Files that you want to manually extract

Modify the variable skipFiles at line 71

To skip folders: add the names of the folders in the strings_to_arb.dart

To skip files: add the name of the file along with its extension.

var skipFiles = ["strings_to_arb.dart", "models", "generated"];

The above code with skip the strings_to_arb.dart file and ‘models’ and ‘generated’ folders.