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

Unified Diff: lib/i18n/intl.dart

Issue 10494005: Updated message formatting to be more compatible with Dart string interpolation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes made from review Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: lib/i18n/intl.dart
diff --git a/lib/i18n/intl.dart b/lib/i18n/intl.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3799b717910b2f7c3efde1c0c8af711b21c25dbc
--- /dev/null
+++ b/lib/i18n/intl.dart
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2012, 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.
+ *
+ */
+
+#library('Intl');
+#import('date_format.dart');
+#import('message_format.dart');
+
+class Intl {
+
+ /**
+ * As yet not clearly defined variable for holding onto our current locale,
+ * which may actually be a list of locales, or have different information
+ * for different aspects of internationalization (e.g. German locale but with
+ * Canadian date format)
+ * TODO(alanknight) Actually make this class do something with locales,
+ * just a skeleton right now.
+ */
+ var _locale;
Emily Fortuna 2012/06/05 00:30:39 this guy should be de-indented one space. It shoul
Alan Knight 2012/06/05 17:24:47 Done.
+
+ /**
+ * Constructor
+ */
+ Intl([this._locale]);
+
+ /**
+ * Methods to return appropriate format objects.
+ */
+ get date() => new DateFormat.date();
+ get time() => new DateFormat.time();
+ get dateTime() => new DateFormat.dateTime();
+ get message() => new MessageFormat();
+
+ /**
+ * Support methods for message formatting.
+ */
+ String plural(num howMany, Map actions) {
+ var desiredKey = howMany.toString();
+ for (var key in actions.getKeys()) {
+ if(desiredKey == key) {return actions[key];}
+ }
+ if (actions.containsKey('other'))
+ {return actions['other'];}
+ else
Emily Fortuna 2012/06/05 00:30:39 Also, preferred formatting for this is: if (blah)
Alan Knight 2012/06/05 17:24:47 Done.
+ {return '';;};
Emily Fortuna 2012/06/05 00:30:39 extra semicolon!
Alan Knight 2012/06/05 17:24:47 Done.
+ }
+
+ String select(String choice, Map actions) {
+ for (var key in actions.getKeys()) {
+ if (choice == key) {return actions[key];};
Emily Fortuna 2012/06/05 00:30:39 the preferred format is if you have a one-line if
Alan Knight 2012/06/05 17:24:47 Done.
+ return '';
Emily Fortuna 2012/06/05 00:30:39 I think this return should be one line down -- oth
Alan Knight 2012/06/05 17:24:47 Oops. Done.
+ }
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698