This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit an example to serve as a pseudo-golden test
- Loading branch information
1 parent
4a1b48f
commit 9070e37
Showing
15 changed files
with
1,926 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
OUTPUT_DIR=lib/generated | ||
|
||
MESSAGE_ARBS=\ | ||
lib/messages/material_de_CH.arb \ | ||
lib/messages/material_de.arb \ | ||
lib/messages/material_en.arb \ | ||
lib/messages/material_es.arb | ||
|
||
# --json \ | ||
# --codegen_mode=debug \ | ||
generate: $(MESSAGE_ARBS) | ||
dart ../bin/generate_from_arb.dart \ | ||
--output-dir $(OUTPUT_DIR) \ | ||
lib/example_messages.dart \ | ||
$(MESSAGE_ARBS) | ||
|
||
clean: | ||
rm $(OUTPUT_DIR)/*.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## What's this? | ||
|
||
This is an example to demonstrate the output from `bin/generate_from_arb.dart`. | ||
|
||
You can see the example generated code in `lib/generated`. | ||
|
||
Note that the Dart code using the Intl messages - `lib/example_messages.dart` - | ||
is atypical Dart code. It exists just to have references to the `Intl.message` | ||
messages from the lib/messages ARB files, so the generator will output the | ||
cooresponding messages in `lib/generated`. | ||
|
||
## Re-generating the example code | ||
|
||
- `cd example` | ||
- `make` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// An example to demonstrate the output from `bin/generate_from_arb.dart`. | ||
|
||
import 'package:intl/intl.dart'; | ||
|
||
import 'generated/messages_all.dart'; | ||
|
||
void main(List<String> args) async { | ||
var locale = args.isNotEmpty ? args[0] : Intl.defaultLocale; | ||
|
||
await initializeMessages(locale); | ||
|
||
print("Displaying messages for the '$locale' locale:"); | ||
print(''); | ||
|
||
Intl.withLocale(locale, () { | ||
printMessages(); | ||
}); | ||
} | ||
|
||
void printMessages() { | ||
show(Intl.message('scriptCategory')); | ||
show(Intl.message('timeOfDayFormat')); | ||
show(Intl.message('openAppDrawerTooltip')); | ||
show(Intl.message('backButtonTooltip')); | ||
show(Intl.message('closeButtonTooltip')); | ||
show(Intl.message('deleteButtonTooltip')); | ||
show(Intl.message('moreButtonTooltip')); | ||
show(Intl.message('nextMonthTooltip')); | ||
show(Intl.message('previousMonthTooltip')); | ||
show(Intl.message('nextPageTooltip')); | ||
show(Intl.message('previousPageTooltip')); | ||
show(Intl.message('firstPageTooltip')); | ||
show(Intl.message('lastPageTooltip')); | ||
show(Intl.message('showMenuTooltip')); | ||
show(Intl.message('aboutListTileTitle')); | ||
show(Intl.message('licensesPageTitle')); | ||
show(Intl.message('licensesPackageDetailTextZero')); | ||
show(Intl.message('licensesPackageDetailTextOne')); | ||
show(Intl.message('licensesPackageDetailTextOther')); | ||
show(Intl.message('pageRowsInfoTitle')); | ||
show(Intl.message('pageRowsInfoTitleApproximate')); | ||
show(Intl.message('rowsPerPageTitle')); | ||
show(Intl.message('tabLabel')); | ||
show(Intl.message('selectedRowCountTitleZero')); | ||
show(Intl.message('selectedRowCountTitleOne')); | ||
show(Intl.message('selectedRowCountTitleOther')); | ||
show(Intl.message('cancelButtonLabel')); | ||
show(Intl.message('closeButtonLabel')); | ||
show(Intl.message('continueButtonLabel')); | ||
show(Intl.message('copyButtonLabel')); | ||
show(Intl.message('cutButtonLabel')); | ||
show(Intl.message('okButtonLabel')); | ||
show(Intl.message('pasteButtonLabel')); | ||
show(Intl.message('selectAllButtonLabel')); | ||
show(Intl.message('viewLicensesButtonLabel')); | ||
show(Intl.message('anteMeridiemAbbreviation')); | ||
show(Intl.message('postMeridiemAbbreviation')); | ||
show(Intl.message('timePickerHourModeAnnouncement')); | ||
show(Intl.message('timePickerMinuteModeAnnouncement')); | ||
show(Intl.message('modalBarrierDismissLabel')); | ||
show(Intl.message('dateSeparator')); | ||
show(Intl.message('dateHelpText')); | ||
show(Intl.message('selectYearSemanticsLabel')); | ||
show(Intl.message('unspecifiedDate')); | ||
show(Intl.message('unspecifiedDateRange')); | ||
show(Intl.message('dateInputLabel')); | ||
show(Intl.message('dateRangeStartLabel')); | ||
show(Intl.message('dateRangeEndLabel')); | ||
show(Intl.message('dateRangeStartDateSemanticLabel')); | ||
show(Intl.message('dateRangeEndDateSemanticLabel')); | ||
show(Intl.message('invalidDateFormatLabel')); | ||
show(Intl.message('invalidDateRangeLabel')); | ||
show(Intl.message('dateOutOfRangeLabel')); | ||
show(Intl.message('saveButtonLabel')); | ||
show(Intl.message('datePickerHelpText')); | ||
show(Intl.message('dateRangePickerHelpText')); | ||
show(Intl.message('calendarModeButtonLabel')); | ||
show(Intl.message('inputDateModeButtonLabel')); | ||
show(Intl.message('timePickerDialHelpText')); | ||
show(Intl.message('timePickerInputHelpText')); | ||
show(Intl.message('timePickerHourLabel')); | ||
show(Intl.message('timePickerMinuteLabel')); | ||
show(Intl.message('invalidTimeLabel')); | ||
show(Intl.message('dialModeButtonLabel')); | ||
show(Intl.message('inputTimeModeButtonLabel')); | ||
show(Intl.message('signedInLabel')); | ||
show(Intl.message('hideAccountsLabel')); | ||
show(Intl.message('showAccountsLabel')); | ||
show(Intl.message('drawerLabel')); | ||
show(Intl.message('menuBarMenuLabel')); | ||
show(Intl.message('popupMenuLabel')); | ||
show(Intl.message('dialogLabel')); | ||
show(Intl.message('alertDialogLabel')); | ||
show(Intl.message('searchFieldLabel')); | ||
show(Intl.message('reorderItemToStart')); | ||
show(Intl.message('reorderItemToEnd')); | ||
show(Intl.message('reorderItemUp')); | ||
show(Intl.message('reorderItemDown')); | ||
show(Intl.message('reorderItemLeft')); | ||
show(Intl.message('reorderItemRight')); | ||
show(Intl.message('expandedIconTapHint')); | ||
show(Intl.message('collapsedIconTapHint')); | ||
show(Intl.message('remainingTextFieldCharacterCountZero')); | ||
show(Intl.message('remainingTextFieldCharacterCountOne')); | ||
show(Intl.message('remainingTextFieldCharacterCountOther')); | ||
show(Intl.message('refreshIndicatorSemanticLabel')); | ||
show(Intl.message('keyboardKeyAlt')); | ||
show(Intl.message('keyboardKeyAltGraph')); | ||
show(Intl.message('keyboardKeyBackspace')); | ||
show(Intl.message('keyboardKeyCapsLock')); | ||
show(Intl.message('keyboardKeyChannelDown')); | ||
show(Intl.message('keyboardKeyChannelUp')); | ||
show(Intl.message('keyboardKeyControl')); | ||
show(Intl.message('keyboardKeyDelete')); | ||
show(Intl.message('keyboardKeyEject')); | ||
show(Intl.message('keyboardKeyEnd')); | ||
show(Intl.message('keyboardKeyEscape')); | ||
show(Intl.message('keyboardKeyFn')); | ||
show(Intl.message('keyboardKeyHome')); | ||
show(Intl.message('keyboardKeyInsert')); | ||
show(Intl.message('keyboardKeyMeta')); | ||
show(Intl.message('keyboardKeyMetaMacOs')); | ||
show(Intl.message('keyboardKeyMetaWindows')); | ||
show(Intl.message('keyboardKeyNumLock')); | ||
show(Intl.message('keyboardKeyNumpad1')); | ||
show(Intl.message('keyboardKeyNumpad2')); | ||
show(Intl.message('keyboardKeyNumpad3')); | ||
show(Intl.message('keyboardKeyNumpad4')); | ||
show(Intl.message('keyboardKeyNumpad5')); | ||
show(Intl.message('keyboardKeyNumpad6')); | ||
show(Intl.message('keyboardKeyNumpad7')); | ||
show(Intl.message('keyboardKeyNumpad8')); | ||
show(Intl.message('keyboardKeyNumpad9')); | ||
show(Intl.message('keyboardKeyNumpad0')); | ||
show(Intl.message('keyboardKeyNumpadAdd')); | ||
show(Intl.message('keyboardKeyNumpadComma')); | ||
show(Intl.message('keyboardKeyNumpadDecimal')); | ||
show(Intl.message('keyboardKeyNumpadDivide')); | ||
show(Intl.message('keyboardKeyNumpadEnter')); | ||
show(Intl.message('keyboardKeyNumpadEqual')); | ||
show(Intl.message('keyboardKeyNumpadMultiply')); | ||
show(Intl.message('keyboardKeyNumpadParenLeft')); | ||
show(Intl.message('keyboardKeyNumpadParenRight')); | ||
show(Intl.message('keyboardKeyNumpadSubtract')); | ||
show(Intl.message('keyboardKeyPageDown')); | ||
show(Intl.message('keyboardKeyPageUp')); | ||
show(Intl.message('keyboardKeyPower')); | ||
show(Intl.message('keyboardKeyPowerOff')); | ||
show(Intl.message('keyboardKeyPrintScreen')); | ||
show(Intl.message('keyboardKeyScrollLock')); | ||
show(Intl.message('keyboardKeySelect')); | ||
show(Intl.message('keyboardKeySpace')); | ||
} | ||
|
||
void show(String message) { | ||
print(" - '$message'"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart | ||
// This is a library that looks up messages for specific locales by | ||
// delegating to the appropriate library. | ||
|
||
export 'messages_all_locales.dart' | ||
show initializeMessages; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart | ||
// This is a library that looks up messages for specific locales by | ||
// delegating to the appropriate library. | ||
|
||
// Ignore issues from commonly used lints in this file. | ||
// ignore_for_file:implementation_imports, file_names | ||
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering | ||
// ignore_for_file:argument_type_not_assignable, invalid_assignment | ||
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases | ||
// ignore_for_file:comment_references | ||
|
||
import 'package:intl/intl.dart'; | ||
import 'package:intl/message_lookup_by_library.dart'; | ||
import 'package:intl/src/intl_helpers.dart'; | ||
|
||
import 'messages_de_CH.dart' deferred as messages_de_ch; | ||
import 'messages_de.dart' deferred as messages_de; | ||
import 'messages_en.dart' deferred as messages_en; | ||
import 'messages_es.dart' deferred as messages_es; | ||
|
||
typedef Future<dynamic> LibraryLoader(); | ||
Map<String, LibraryLoader> _deferredLibraries = { | ||
'de_CH': messages_de_ch.loadLibrary, | ||
'de': messages_de.loadLibrary, | ||
'en': messages_en.loadLibrary, | ||
'es': messages_es.loadLibrary, | ||
}; | ||
|
||
MessageLookupByLibrary? _findExact(String localeName) { | ||
switch (localeName) { | ||
case 'de_CH': | ||
return messages_de_ch.messages; | ||
case 'de': | ||
return messages_de.messages; | ||
case 'en': | ||
return messages_en.messages; | ||
case 'es': | ||
return messages_es.messages; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
/// User programs should call this before using [localeName] for messages. | ||
Future<bool> initializeMessages(String? localeName) async { | ||
var availableLocale = Intl.verifiedLocale( | ||
localeName, | ||
(locale) => _deferredLibraries[locale] != null, | ||
onFailure: (_) => null); | ||
if (availableLocale == null) { | ||
return Future.value(false); | ||
} | ||
var lib = _deferredLibraries[availableLocale]; | ||
await (lib == null ? Future.value(false) : lib()); | ||
initializeInternalMessageLookup(() => CompositeMessageLookup()); | ||
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); | ||
return Future.value(true); | ||
} | ||
|
||
bool _messagesExistFor(String locale) { | ||
try { | ||
return _findExact(locale) != null; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { | ||
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, | ||
onFailure: (_) => null); | ||
if (actualLocale == null) return null; | ||
return _findExact(actualLocale); | ||
} |
Oops, something went wrong.