load method

  1. @override
Future<CupertinoLocalizations> load(
  1. Locale locale
)
override

Start loading the resources for locale. The returned future completes when the resources have finished loading.

It's assumed that this method will return an object that contains a collection of related string resources (typically defined with one method per resource). The object will be retrieved with Localizations.of.

Implementation

@override
Future<CupertinoLocalizations> load(Locale locale) async {
  final String localeName = intl.Intl.canonicalizedLocale(locale.toString());
  // The locale (in this case `nn`) needs to be initialized into the custom
  // date symbols and patterns setup that Flutter uses.
  date_symbol_data_custom.initializeDateFormattingCustom(
    locale: localeName,
    patterns: kurdishLocaleDatePatterns,
    symbols: intl.DateSymbols.deserializeFromMap(kuDateSymbols2),
  );

  return SynchronousFuture<CupertinoLocalizations>(
    KurdishCupertinoLocalizations(
        localeName: localeName,

        // The `intl` library's NumberFormat class is generated from CLDR data
        // (see https://github.com/dart-lang/intl/blob/master/lib/number_symbols_data.dart).
        // Unfortunately, there is no way to use a locale that isn't defined in
        // this map and the only way to work around this is to use a listed
        // locale's NumberFormat symbols. So, here we use the number formats
        // for 'en_US' instead.
        decimalFormat: intl.NumberFormat('#,##0.###', 'ar'),
        // DateFormat here will use the symbols and patterns provided in the
        // `date_symbol_data_custom.initializeDateFormattingCustom` call above.
        // However, an alternative is to simply use a supported locale's
        // DateFormat symbols, similar to NumberFormat above.
        fullYearFormat: intl.DateFormat('y', localeName),
        dayFormat: intl.DateFormat('yMd', localeName),
        doubleDigitMinuteFormat: intl.DateFormat('yMMMd', localeName),
        mediumDateFormat: intl.DateFormat('EEE, MMM d', localeName),
        singleDigitHourFormat: intl.DateFormat('EEEE, MMMM d, y', localeName),
        singleDigitMinuteFormat: intl.DateFormat('MMMM y', localeName),
        singleDigitSecondFormat: intl.DateFormat('MMM d', localeName),
        weekdayFormat: intl.DateFormat('EEE', localeName)),
  );
}