I'm having trouble implementing internationalization of DateFormat.

I use the below code to get the date formatted:

var time = DateTime.fromMillisecondsSinceEpoch(item['time'] * 1000);
${DateFormat('EEEE, MMMM d').format(time)}

returns Friday, February 6

Changing my device to another language, continues to return Friday, February 6.

The internationalization of other Strings within the app (those manually translated) are working as intended.

Below is the code which initializes localizationsDelegates.

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  MyApp();

  @override
  MyAppStateful createState() => MyAppStateful();
}

class MyAppStateful extends State<MyApp> {
  MyAppStateful();

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      localizationsDelegates: [
        // ... app-specific localization delegate[s] here
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        AppLocalizations.delegate,
      ],
      supportedLocales: supportedLocales,
      localeResolutionCallback: (locale, supportedLocales) {
        for (var i in supportedLocales) {
          if (i.languageCode == locale.languageCode) {
            return i;
          }
        }
        return supportedLocales.first;
      },
      home: isX ? Y() : Z(),
    );
  }
}

My question is two fold:

1) How can I have a translated DateFormat of the current date?

2) Is it possible to localize the DateFormat formatting? Instead of forcing it to be: DateFormat('EEEE, MMMM d').format(time)} have it be flexible to locale?
E.g.: In the US it's Weekday, Month Day, but in France it's Weekday Day Month.


Solution 1: Dmitry Shiryhalov

Actually, I don't know about second fold, but for the first you can use smth like this:

var time = DateTime.fromMillisecondsSinceEpoch(item['time'] * 1000);
${DateFormat('EEEE, MMMM d', Localizations.localeOf(context).toString()).format(time)}


Solution 2: poultrynews

The key to solving point #2 is using DateFormat's integrated patterns:

DateFormat.yMMMMd(Localizations.localeOf(context).toString()).format(time) returns the correct formatting wrt to user's locale.