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

localization key in MaterialApp #337

Open
Overman775 opened this issue Feb 17, 2021 · 5 comments
Open

localization key in MaterialApp #337

Overman775 opened this issue Feb 17, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@Overman775
Copy link
Collaborator

if getting locale keys from under widget MaterialApp _translations not loaded... but in childrens all ok

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: LocaleKeys.title.tr(), /// bug _translations empty
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
      locale: context.locale,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Easy localization'),
    );
  }
}
@Overman775 Overman775 added the bug Something isn't working label Feb 17, 2021
@Overman775
Copy link
Collaborator Author

dublicate #331

@Overman775
Copy link
Collaborator Author

Overman775 commented Feb 17, 2021

minor fixed in PR #336
@aissat but the keys are loading when translations not initiliased

I/flutter (12784): [🌎 Easy Localization] [DEBUG] Localization initialized
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Start
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Init state
I/flutter (12784): [🌎 Easy Localization] [INFO] Start locale loaded vi
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Build
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Init Localization Delegate
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Init provider
I/flutter (12784): [🌎 Easy Localization] [WARNING] Localization key [name] not found  <--------
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Load Localization Delegate
I/flutter (12784): [🌎 Easy Localization] [DEBUG] Load asset from assets/translations

@aissat
Copy link
Owner

aissat commented Mar 9, 2021

Duplicate of #349 #351 #355

@EhabSalah
Copy link

is there any news or workarounds for this bug?

MaterialApp's title couldn't be translated!!

@GoodLucky777
Copy link

is there any news or workarounds for this bug?

MaterialApp's title couldn't be translated!!

It looks like it's working with onGenerateTitle (https://api.flutter.dev/flutter/material/MaterialApp/onGenerateTitle.html)

MaterialApp(
    ...
    title: 'Title',
    onGenerateTitle: (context) => 'title'.tr(),
    ...
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants