long1eu / flutter_i18n

This plugin create a binding between your translations from .arb files and your Flutter app.
Apache License 2.0
251 stars 55 forks source link

Plugin don't work #92

Closed FilipeOS closed 5 years ago

FilipeOS commented 5 years ago

Hi guys,

Sorry if I'm too noob for this.

So, I installed the plugin according this instructions and it worked (no errors), until I get packages on pubspec and restart Android Studio.

After that I tried the github instructions on the README section and still don't work...

When I place this on main.dart it says undefined name:

localizationsDelegates: [
            S.delegate,
            // You need to add them if you are using the material library.
            // The material components usses this delegates to provide default 
            // localization 
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: S.delegate.supportedLocales,

      localeResolutionCallback:
          S.delegate.resolution(fallback: const Locale('en', '')),
      // this is equivalent to having withCountry: false, as in the next call:
      localeResolutionCallback:
          S.delegate.resolution(fallback: const Locale('en', ''), withCountry: false),

Am I missing something or instructions are unclear/missing details? Thank you!

noordawod commented 5 years ago

@FilipeOS

1) Do you see a lib/generated/i18n.dart file in your source tree?

2) Did you import this file in main.dart?

FilipeOS commented 5 years ago

Hi @noordawod ,

  1. No, I don't see it.
  2. I try to auto import but no suggestion shows up sorry
noordawod commented 5 years ago

If you don't see the lib/generated/i18n.dart file, it means the plugin isn't installed properly... Try to remove and reinstall it, and send a screenshot of the Plugin screen after restarting the IDE showing the state of the plugin installation.

FilipeOS commented 5 years ago

@noordawod Invalidate Cache and Restart worked like always.

Now GlobalMaterialLocalizations.delegate, and GlobalWidgetsLocalizations.delegate, is not definied

        title: _appTitle,
        debugShowCheckedModeBanner: false,
        localizationsDelegates: [
          S.delegate,
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: S.delegate.supportedLocales,
        localeResolutionCallback:
        S.delegate.resolution(fallback: const Locale('en', '')),
noordawod commented 5 years ago

That's unrelated to this plugin, but you should be able to import the relevant Flutter modules to expose those. Check the documentation.