Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #584 from dart-lang:fixDateFormattingUrl
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 525079636
  • Loading branch information
copybara-github committed Apr 18, 2023
2 parents b0d5687 + 4ea644e commit 5c14faa
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions lib/date_symbol_data_http_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,41 @@ export 'src/data/dates/locale_list.dart';
/// The [url] parameter should end with a "/". For example,
/// "http://localhost:8000/dates/"
Future<void> initializeDateFormatting(String locale, String url) {
var reader = HttpRequestDataReader('${url}symbols/');
initializeDateSymbols(() => LazyLocaleData(
reader, _createDateSymbol, availableLocalesForDateFormatting));
var reader2 = HttpRequestDataReader('${url}patterns/');
initializeDatePatterns(() =>
LazyLocaleData(reader2, (x) => x, availableLocalesForDateFormatting));
var actualLocale =
Intl.verifiedLocale(locale, availableLocalesForDateFormatting.contains);
return initializeIndividualLocaleDateFormatting((symbols, patterns) {
return Future.wait(<Future<List<dynamic>>>[
//Initialize symbols
var symbolReader = HttpRequestDataReader('${url}symbols/');
LazyLocaleData symbolsInitializer() => LazyLocaleData(
symbolReader,
_createDateSymbol,
availableLocalesForDateFormatting,
);
initializeDateSymbols(symbolsInitializer);

//Initialize patterns
var patternsReader = HttpRequestDataReader('${url}patterns/');
LazyLocaleData patternsInitializer() => LazyLocaleData(
patternsReader,
(x) => x,
availableLocalesForDateFormatting,
);
initializeDatePatterns(patternsInitializer);

var actualLocale = Intl.verifiedLocale(
locale,
availableLocalesForDateFormatting.contains,
)!;

//Initialize locale for both symbols and patterns
Future<List<void>> initLocale(
LazyLocaleData symbols,
LazyLocaleData patterns,
) {
return Future.wait([
symbols.initLocale(actualLocale),
patterns.initLocale(actualLocale)
patterns.initLocale(actualLocale),
]);
});
}

return initializeIndividualLocaleDateFormatting(initLocale);
}

/// Defines how new date symbol entries are created.
Expand Down

0 comments on commit 5c14faa

Please sign in to comment.