October 21, 2024
Chicago 12, Melborne City, USA
Android

How to split Flutter ARB localization files by feature in a clean code folder structure?


I am working on a Flutter project following a clean code architecture, and I use ARB files for localization. I’d like to organize the translation files within each feature and component, but I’m unsure of the best way to structure them. Currently, my project looks like this:

lib/
  ├── features/
  │    ├── feature_1/
  │    │    ├── data/
  │    │    ├── domain/
  │    │    ├── presentation/
  ├── l10n/    
  └── main.dart

My goal is to move the localization files closer to each feature, like this:

lib/
  ├── features/
  │    ├── feature_1/
  │    │    ├── data/
  │    │    ├── domain/
  │    │    ├── presentation/
  │    │    │    └── l10n/
  │    │    │         ├── feature_1_en.arb
  │    │    │         └── feature_1_de.arb
  └── main.dart

Some specific questions I have:

  1. Is there a way to split the translation .arb files so that they reside inside each feature’s presentation folder (e.g., lib/features/feature_1/presentation/l10n)?
  2. Would placing the ARB files inside feature-specific folders still allow the localization logic to work correctly, or would there be limitations in managing them this way?
  3. Are there any recommended practices or tools for handling feature-based localization in a clean code architecture?

Any advice or examples would be greatly appreciated!



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video