Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key [description] not found #351

Closed
SebastianKumor opened this issue Mar 4, 2021 · 12 comments
Closed

key [description] not found #351

SebastianKumor opened this issue Mar 4, 2021 · 12 comments

Comments

@SebastianKumor
Copy link

SebastianKumor commented Mar 4, 2021

This is my main, i am running this for web only

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  runApp(EasyLocalization(
      supportedLocales: [Locale('en'), Locale('da')],
      useOnlyLangCode: true,
      path: 'assets/languages',
      startLocale: Locale('en'),
      child: MyApp()));

I get

🌎 Easy Localization] [WARNING] Localization key [description] not found

and my folder structure is like so

assets
└── languages
    ├── en.json
    └── da.json 

my json file looks like this

{
    "description" : "Hue huehue"
}

Any idea what am I doing wrong ? The example app is using some generated file but mine did not generate anything.

@SebastianKumor SebastianKumor changed the title Failed to load asset at error key [description] not found Mar 4, 2021
@Overman775
Copy link
Collaborator

Locale('dk')?? maybe you meen Locale('da') Danish - Denmark?

https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

@SebastianKumor
Copy link
Author

SebastianKumor commented Mar 5, 2021

  • @Overman775 yeah i noticed that and fixed it but still the the same problem. Does not work with 'en' either

@Overman775
Copy link
Collaborator

@SebastianKumor try set flag useOnlyLangCode to true

@SebastianKumor
Copy link
Author

@Overman775 I tried, if you check the code I posted the flag is set there. Is there some other place it should be set as well?

@Overman775
Copy link
Collaborator

@SebastianKumor hhmm... web try clean cache. May be this bug #303

@SebastianKumor
Copy link
Author

@Overman775 i will try that thanks :)

@Misikir
Copy link

Misikir commented Mar 5, 2021

  
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(       
        primarySwatch: Colors.blue,
      ),
      localizationsDelegates: context.localizationDelegates, // <-- add this
      supportedLocales: context.supportedLocales, // <-- add this
      locale: context.locale, // <-- add this
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

@SebastianKumor
Copy link
Author

@Misikir I have that there and no change

@charantft
Copy link

@aissat Plz give a solution to this issue. Having this issue after upgrading null safety version(3.0.0)

@SebastianKumor
Copy link
Author

@Overman775 @aissat I wrapped my app in another widget as mentioned in #349 but I still get key not found error.

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  final Future<FirebaseApp> _initialization = Firebase.initializeApp();

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      // Initialize FlutterFire:
      future: _initialization,
      builder: (context, snapshot) {
        // Check for errors
        if (snapshot.hasError) {
          return MyPlaceholder();
        }
        // Once complete, show your application
        if (snapshot.connectionState == ConnectionState.done) {
          /
          return MaterialApp(
              localizationsDelegates: context.localizationDelegates,
              supportedLocales: context.supportedLocales,
              locale: context.locale,
              title: 'Aerone',
              theme: ThemeData(fontFamily: 'MetropolisRegular'),
              home: Home());
        }

        // Otherwise, show something whilst waiting for initialization to complete
        return MaterialApp(
            home: Scaffold(body: MyPlaceholderError()),
            title: 'Aerone',
            theme: ThemeData(fontFamily: 'MetropolisRegular'));
      },
    );
  }
}

and here is the home class

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body:
            MainPage() // This trailing comma makes auto-formatting nicer for build methods.
        );
  }
}

I still get this in the debug console

[🌎 Easy Localization] [DEBUG] Localization initialized
[🌎 Easy Localization] [DEBUG] Start
[🌎 Easy Localization] [DEBUG] Init state
[🌎 Easy Localization] [INFO] Start locale loaded en
[🌎 Easy Localization] [DEBUG] Build
[🌎 Easy Localization] [DEBUG] Init Localization Delegate
[🌎 Easy Localization] [DEBUG] Init provider
[🌎 Easy Localization] [DEBUG] Load Localization Delegate
[🌎 Easy Localization] [DEBUG] Load asset from web/languages
[🌎 Easy Localization] [WARNING] Localization key [test_title] not found

@Overman775
Copy link
Collaborator

@SebastianKumor this code look dirty... try use one MaterialApp

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  final Future<FirebaseApp> _initialization = Firebase.initializeApp();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
      locale: context.locale,
      title: 'Aerone',
      theme: ThemeData(fontFamily: 'MetropolisRegular'),
      home: FutureBuilder(
        future: _initialization,
        builder: (context, snapshot) {
          // Check for errors
          if (snapshot.hasError) {
            return MyPlaceholder();
          }
          // Once complete, show your application
          if (snapshot.connectionState == ConnectionState.done) {
            return Home();
          }

          // Otherwise, show something whilst waiting for initialization to complete
          return MyPlaceholderError();
        },
      ),
    );
  }
}

@SebastianKumor
Copy link
Author

@Overman775 you were right, that fixed the problem. I will close this issue now

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants