Atiq Ur Rehman
Atiq Ur Rehman

Reputation: 1235

Flutter easy localization Source path does not exist

I'm trying to add Spanish to my flutter project with easy_localization i added JSON files of US and ES and added the path to it in runApp function as I try to generate keys with flutter

pub run easy_localization:generate
runApp(EasyLocalization(
      supportedLocales: [Locale('en', 'US'), Locale('es', 'ES')],
      path: 'assets/translations/',
      fallbackLocale: Locale('en', 'US'),
      child: MyApp()));

Upvotes: 13

Views: 11114

Answers (7)

Ahmed Gabr
Ahmed Gabr

Reputation: 303

I encountered the same issue. Previously, the following command worked for me:

dart run easy_localization:generate -S "assets/translations" -O "lib/translations" -o "locale_keys.g.dart" -f keys

However, today it stopped working.

The issue seems to be related to the Android Studio terminal. Try running the command in the Windows Command Prompt instead. it should work fine.

Upvotes: 0

Furkan Cetintas
Furkan Cetintas

Reputation: 822

try the following code:

flutter pub run easy_localization:generate -O lib/core/lang -f keys -o locale_keys.g.dart --source-dir ./assets/lang

Upvotes: 4

Jitesh Mohite
Jitesh Mohite

Reputation: 34180

Make sure translations file path is given properly in below command, also add locale_keys.g.dart to generate a file with the same name.

flutter pub run easy_localization:generate --source-dir ./assets/translations -f keys -o locale_keys.g.dart

Usage:

import 'package:easy_localization/easy_localization.dart';

LocaleKeys.Name /// Similar way find your keys which declared inside .json file

Upvotes: 1

Naresh Khatri
Naresh Khatri

Reputation: 1

Remove /(forwad slash symbol) from path Like path:"assets/translations"

that's it.

Upvotes: 0

xkxeeshankhan
xkxeeshankhan

Reputation: 431

In case someone get the same error while generating locale_keys.g.dart use the below code:

flutter pub run easy_localization:generate -S assets/translations -f keys -o locale_keys.g.dart

Upvotes: 22

Jay Dangar
Jay Dangar

Reputation: 3469

try the following code :

flutter pub run easy_localization:generate -s assets/translations

Upvotes: 0

Atiq Ur Rehman
Atiq Ur Rehman

Reputation: 1235

simply just put the path of the folder where localization files are, in my case.

flutter pub run easy_localization:generate --source-dir ./assets/translations

Upvotes: 34

Related Questions