Home > Software engineering >  How I can set the default language in flutter using easy localization?
How I can set the default language in flutter using easy localization?

Time:09-02

I'm trying to set the Arabic 'ar' the default language for my app, but it still launch in English.

Here's my code in the runApp in main.dart

runApp(
  EasyLocalization(
    supportedLocales: [
      Locale('en'),
      Locale('ar'),
    ],
    fallbackLocale: Locale('en'),
    assetLoader: CodegenLoader(),
    path: 'assets/translations',
    startLocale: Locale('ar'),
    child: MyApp(),
  ),
); 

CodePudding user response:

You can read this, step by step :

https://blog.logrocket.com/internationalizing-app-flutter-easy-localization/

It is well explained.

CodePudding user response:

return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en'),
        const Locale('ar'),
      ],
      locale: const Locale('ar'),
);
  • Related