| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * This provides utilities for generating localized versions of | 6 * This provides utilities for generating localized versions of |
| 7 * messages. It does not stand alone, but expects to be given | 7 * messages. It does not stand alone, but expects to be given |
| 8 * TranslatedMessage objects and generate code for a particular locale | 8 * TranslatedMessage objects and generate code for a particular locale |
| 9 * based on them. | 9 * based on them. |
| 10 * | 10 * |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 .map((translation) => translation.originalMessage.name) | 99 .map((translation) => translation.originalMessage.name) |
| 100 .map((name) => " \"$name\" : $name"); | 100 .map((name) => " \"$name\" : $name"); |
| 101 result.write(entries.join(",\n")); | 101 result.write(entries.join(",\n")); |
| 102 result.write("\n };\n}"); | 102 result.write("\n };\n}"); |
| 103 | 103 |
| 104 var output = new File(path.join(targetDir, "messages_$locale.dart")); | 104 var output = new File(path.join(targetDir, "messages_$locale.dart")); |
| 105 output.writeAsStringSync(result.toString()); | 105 output.writeAsStringSync(result.toString()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * This returns the mostly constant string used in [generated] for the | 109 * This returns the mostly constant string used in |
| 110 * [generateIndividualMessageFile] for the |
| 110 * beginning of the file, parameterized by [locale]. | 111 * beginning of the file, parameterized by [locale]. |
| 111 */ | 112 */ |
| 112 String prologue(String locale) => """ | 113 String prologue(String locale) => """ |
| 113 /** | 114 /** |
| 114 * DO NOT EDIT. This is code generated via pkg/intl/generate_localized.dart | 115 * DO NOT EDIT. This is code generated via pkg/intl/generate_localized.dart |
| 115 * This is a library that provides messages for a $locale locale. All the | 116 * This is a library that provides messages for a $locale locale. All the |
| 116 * messages from the main program should be duplicated here with the same | 117 * messages from the main program should be duplicated here with the same |
| 117 * function name. | 118 * function name. |
| 118 */ | 119 */ |
| 119 | 120 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 library messages_all; | 166 library messages_all; |
| 166 | 167 |
| 167 import 'dart:async'; | 168 import 'dart:async'; |
| 168 import 'package:$intlImportPath/message_lookup_by_library.dart'; | 169 import 'package:$intlImportPath/message_lookup_by_library.dart'; |
| 169 import 'package:$intlImportPath/src/intl_helpers.dart'; | 170 import 'package:$intlImportPath/src/intl_helpers.dart'; |
| 170 import 'package:$intlImportPath/intl.dart'; | 171 import 'package:$intlImportPath/intl.dart'; |
| 171 | 172 |
| 172 """; | 173 """; |
| 173 | 174 |
| 174 /** | 175 /** |
| 175 * Constant string used in [generateMainImportfile] as the end of the file. | 176 * Constant string used in [generateMainImportFile] as the end of the file. |
| 176 */ | 177 */ |
| 177 const closing = """ | 178 const closing = """ |
| 178 default: return null; | 179 default: return null; |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 | 182 |
| 182 /** User programs should call this before using [localeName] for messages.*/ | 183 /** User programs should call this before using [localeName] for messages.*/ |
| 183 initializeMessages(localeName) { | 184 initializeMessages(localeName) { |
| 184 initializeInternalMessageLookup(() => new CompositeMessageLookup()); | 185 initializeInternalMessageLookup(() => new CompositeMessageLookup()); |
| 185 messageLookup.addLocale(localeName, _findGeneratedMessagesFor); | 186 messageLookup.addLocale(localeName, _findGeneratedMessagesFor); |
| 186 return new Future.value(); | 187 return new Future.value(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 MessageLookupByLibrary _findGeneratedMessagesFor(locale) { | 190 MessageLookupByLibrary _findGeneratedMessagesFor(locale) { |
| 190 var actualLocale = Intl.verifiedLocale(locale, (x) => _findExact(x) != null); | 191 var actualLocale = Intl.verifiedLocale(locale, (x) => _findExact(x) != null); |
| 191 if (actualLocale == null) return null; | 192 if (actualLocale == null) return null; |
| 192 return _findExact(actualLocale); | 193 return _findExact(actualLocale); |
| 193 } | 194 } |
| 194 """; | 195 """; |
| OLD | NEW |