Flutter Intl plugin – I am failing to set the location of l10n directory that is generated

156 views Asked by At

Hey I am building a flutter app and I am using the android studio flutter intl plugin, I want the generated files to be in src/shared/core/ but every time I generate them the go in the lib/ directory.

app/
- lib/
  - src/
    - features/
      - auth/
        - data/
        - domain/
        - presentation/
      - shared/
        - config/
        - core/
        - widgets/

Here is my l10n.yaml file, I tried following the documentation but it's not working and It is generating the files in lib.

synthetic-package : false
arb-dir: lib/src/shared/core/l10n
output-dir: lib/src/shared/core/
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
1

There are 1 answers

0
Omar Emad On BEST ANSWER

I fixed it, the fix didn't make that much sense but it worked. First I run

flutter clean

then I moved the generated and l10n directories from lib (default) to core, I then changed the output-dir in l10.yaml and added generated to the end

output-dir: lib/src/shared/core/generated

Then I made sure I have these in my pubspec.yaml

flutter:
  generate: true

and

dependencies:
  flutter_localizations:
      sdk: flutter

Then I commented everything with App localization and S and run the app, I then uncommented all the lines and reimported AppLocalization and S.