Organise .arb files in flutter using Flutter intl extension

3.7k Views Asked by At

Running Flutter Intl: Initialize generates lib/l10n/intl_en.arb. However due to many strings in my applications I would wish to have multiple arb files for same language.

To make it more clear, consider the following folder structure

 -->lib
    --> screens
        --> screen_a.dart
        --> screen_b.dart

Correspondingly I would have my l10n folder structure as follows:

--> l10n
   --> screen_a
       --> intl_en.dart
       --> intl_fr_FR.dart
   --> screen_b
       --> intl_en.dart
       --> intl_fr_FR.dart

How do I achieve this using flutter intl plugin?
Thanks in advance!

2

There are 2 best solutions below

0
On

This project may be of help.

It might be a drawback to some that it uses the go-language to generate localisation files.

It follows the flutter_localizations style, in how the translations are written and documented as well as the generated files.

The added advantage is that it supports grouping of localizations not only by the folders but also supports grouping by feature (or whatever you would like to group the localizations by) so that they can be referenced as follows: AppLocalizations.of(context)!.profile.name

Check out this example for more information on how this works.

I hope it helps.

0
On

Package Intl_translation can handle multiple arb source files since 0.17.5:

Allow multiple ARB files with the same locale and combine their translations.