easy_localization icon indicating copy to clipboard operation
easy_localization copied to clipboard

localization key in MaterialApp

Open Overman775 opened this issue 4 years ago • 5 comments

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 avatar Feb 17 '21 10:02 Overman775

dublicate #331

Overman775 avatar Feb 17 '21 10:02 Overman775

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

Overman775 avatar Feb 17 '21 11:02 Overman775

Duplicate of #349 #351 #355

aissat avatar Mar 09 '21 16:03 aissat

is there any news or workarounds for this bug?

MaterialApp's title couldn't be translated!!

EhabSalah avatar Jun 15 '21 00:06 EhabSalah

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(),
    ...
)

GoodLucky777 avatar Apr 11 '22 01:04 GoodLucky777