avafab
avafab

Reputation: 1701

Easy Localization: Localization key [...] not found

I am using easy_localization: ^2.3.3 in a flutter project with CSV loader. When I build it is not able to find keys and it gives "Easy Localization: Localization key [...] not found". Any ideas why is this happening?


runApp(EasyLocalization(
    supportedLocales: [
      Locale('en', ''),
      Locale('it', ''),
      Locale('es', ''),
      Locale('de', ''),
      Locale('fr', ''),
      Locale('pt', ''),
    ],
    path: 'resources/langs/langs.csv',
    fallbackLocale: Locale('en', ''),
    saveLocale: false,
    useOnlyLangCode: true,
    assetLoader: CsvAssetLoader(),
    child: MyApp(status),
  ));
}

Upvotes: 22

Views: 14713

Answers (3)

Artur
Artur

Reputation: 827

You need to import import 'package:easy_localization/easy_localization.dart';

And add in your MaterialApp :

locale: context.locale,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,

Upvotes: 4

leylekseven
leylekseven

Reputation: 789

Also this error can be happen for not setting the material app; I mean, I got same error for forgeting the add these lines to my material app;

MaterialApp(
    locale: context.locale,
    supportedLocales: context.supportedLocales,
    localizationsDelegates: context.localizationDelegates,
  ),

and my problem solved !

Upvotes: 42

avafab
avafab

Reputation: 1701

I found a solution looking at this bug: https://github.com/aissat/easy_localization/issues/190#

I added the following:

dependencies:
  easy_localization_loader:
    git:
      url: git://github.com/aissat/easy_localization_loader.git
      ref: overman-dev

then I did a

flutter pub upgrade

and also changed the code into this

runApp(EasyLocalization(
    supportedLocales: [
      Locale('en'),
      Locale('it'),
      Locale('es'),
      Locale('de'),
      Locale('fr'),
      Locale('pt'),
    ],
    path: 'resources/langs/langs.csv',
    fallbackLocale: Locale('en'),
    saveLocale: false,
    useOnlyLangCode: true,
    assetLoader: CsvAssetLoader(),
    child: MyApp(status),
  ));

It worked.

Upvotes: 1

Related Questions