|
| 1 | +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart |
| 2 | +// This is a library that looks up messages for specific locales by |
| 3 | +// delegating to the appropriate library. |
| 4 | + |
| 5 | +// Ignore issues from commonly used lints in this file. |
| 6 | +// ignore_for_file:implementation_imports, file_names, unnecessary_new |
| 7 | +// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering |
| 8 | +// ignore_for_file:argument_type_not_assignable, invalid_assignment |
| 9 | +// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases |
| 10 | +// ignore_for_file:comment_references |
| 11 | + |
| 12 | +import 'dart:async'; |
| 13 | + |
| 14 | +import 'package:flutter/foundation.dart'; |
| 15 | +import 'package:intl/intl.dart'; |
| 16 | +import 'package:intl/message_lookup_by_library.dart'; |
| 17 | +import 'package:intl/src/intl_helpers.dart'; |
| 18 | + |
| 19 | +import 'messages_en.dart' as messages_en; |
| 20 | +import 'messages_zh.dart' as messages_zh; |
| 21 | + |
| 22 | +typedef Future<dynamic> LibraryLoader(); |
| 23 | +Map<String, LibraryLoader> _deferredLibraries = { |
| 24 | + 'en': () => new SynchronousFuture(null), |
| 25 | + 'zh': () => new SynchronousFuture(null), |
| 26 | +}; |
| 27 | + |
| 28 | +MessageLookupByLibrary? _findExact(String localeName) { |
| 29 | + switch (localeName) { |
| 30 | + case 'en': |
| 31 | + return messages_en.messages; |
| 32 | + case 'zh': |
| 33 | + return messages_zh.messages; |
| 34 | + default: |
| 35 | + return null; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +/// User programs should call this before using [localeName] for messages. |
| 40 | +Future<bool> initializeMessages(String localeName) { |
| 41 | + var availableLocale = Intl.verifiedLocale( |
| 42 | + localeName, (locale) => _deferredLibraries[locale] != null, |
| 43 | + onFailure: (_) => null); |
| 44 | + if (availableLocale == null) { |
| 45 | + return new SynchronousFuture(false); |
| 46 | + } |
| 47 | + var lib = _deferredLibraries[availableLocale]; |
| 48 | + lib == null ? new SynchronousFuture(false) : lib(); |
| 49 | + initializeInternalMessageLookup(() => new CompositeMessageLookup()); |
| 50 | + messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); |
| 51 | + return new SynchronousFuture(true); |
| 52 | +} |
| 53 | + |
| 54 | +bool _messagesExistFor(String locale) { |
| 55 | + try { |
| 56 | + return _findExact(locale) != null; |
| 57 | + } catch (e) { |
| 58 | + return false; |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { |
| 63 | + var actualLocale = |
| 64 | + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); |
| 65 | + if (actualLocale == null) return null; |
| 66 | + return _findExact(actualLocale); |
| 67 | +} |
0 commit comments