Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: pkg/intl/lib/src/intl_helpers.dart

Issue 12733003: Adds facilities for extracting Intl.message calls and generating code from translations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 * A library for general helper code associated with the intl library 6 * A library for general helper code associated with the intl library
7 * rather than confined to specific parts of it. 7 * rather than confined to specific parts of it.
8 */ 8 */
9 9
10 library intl_helpers; 10 library intl_helpers;
11 import '../date_symbols.dart'; 11 import '../date_symbols.dart';
12 12
13 import 'dart:async'; 13 import 'dart:async';
14 14
15 /** 15 /**
16 * This is used as a marker for a locale data map that hasn't been initialized, 16 * This is used as a marker for a locale data map that hasn't been initialized,
17 * and will throw an exception on any usage that isn't the fallback 17 * and will throw an exception on any usage that isn't the fallback
18 * patterns/symbols provided. 18 * patterns/symbols provided.
19 */ 19 */
20 class UninitializedLocaleData<F> { 20 class UninitializedLocaleData<F> {
21 final String message; 21 final String message;
22 final F fallbackData; 22 final F fallbackData;
23 const UninitializedLocaleData(this.message, this.fallbackData); 23 const UninitializedLocaleData(this.message, this.fallbackData);
24 24
25 operator [](String key) => 25 operator [](String key) =>
26 (key == 'en_US') ? fallbackData : _throwException(); 26 (key == 'en_US') ? fallbackData : _throwException();
27
28 String lookupMessage(String message_str, [final String desc='',
29 final Map examples=const {}, String locale,
30 String name, List<String> args]) => _throwException();
31
27 List get keys => _throwException(); 32 List get keys => _throwException();
33
28 bool containsKey(String key) => (key == 'en_US') ? true : _throwException(); 34 bool containsKey(String key) => (key == 'en_US') ? true : _throwException();
29 35
30 _throwException() { 36 _throwException() {
31 throw new LocaleDataException("Locale data has not been initialized" 37 throw new LocaleDataException("Locale data has not been initialized"
32 ", call $message."); 38 ", call $message.");
33 } 39 }
34 } 40 }
35 41
36 class LocaleDataException implements Exception { 42 class LocaleDataException implements Exception {
37 final String message; 43 final String message;
(...skipping 19 matching lines...) Expand all
57 /** 63 /**
58 * Initialize the message lookup mechanism. This is for internal use only. 64 * Initialize the message lookup mechanism. This is for internal use only.
59 * User applications should import `message_lookup_local.dart` and call 65 * User applications should import `message_lookup_local.dart` and call
60 * `initializeMessages` 66 * `initializeMessages`
61 */ 67 */
62 void initializeInternalMessageLookup(Function lookupFunction) { 68 void initializeInternalMessageLookup(Function lookupFunction) {
63 if (messageLookup is UninitializedLocaleData) { 69 if (messageLookup is UninitializedLocaleData) {
64 messageLookup = lookupFunction(); 70 messageLookup = lookupFunction();
65 } 71 }
66 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698