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

Unified Diff: pkg/intl/lib/intl.dart

Issue 132963002: Read Intl.message examples argument as a map, not a string (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | pkg/intl/lib/src/intl_message.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/intl.dart
diff --git a/pkg/intl/lib/intl.dart b/pkg/intl/lib/intl.dart
index 7fff85070a5e425ddea71852a0fac0165fd33194..200b1569aab4846e5e6c4220d8a64ced14449e6c 100644
--- a/pkg/intl/lib/intl.dart
+++ b/pkg/intl/lib/intl.dart
@@ -129,22 +129,35 @@ class Intl {
}
/**
- * Returns a message that can be internationalized. It takes a
- * [message_str] that will be translated, which may be interpolated
+ * Returns a message that can be internationalized. It is expected
Emily Fortuna 2014/01/10 01:40:56 while you're changing this comment, let's make it
+ * to be used inside an enclosing function that just returns its value
+ * and provides a scope for the variables to be substituted in the
+ * message. The parameters are a
+ * [message_str] to be translated, which may be interpolated
* based on one or more variables, a [desc] providing a description of usage
- * for the [message_str], and a map of [examples] for each data element to be
- * substituted into the message. For example, if message="Hello, $name", then
- * examples = {'name': 'Sparky'}. If not using the user's default locale, or
- * if the locale is not easily detectable, explicitly pass [locale].
- * The values of [desc] and [examples] are not used at run-time but are only
- * made available to the translators, so they MUST be simple Strings available
- * at compile time: no String interpolation or concatenation.
+ * and a map of [examples] for each interpolated variable. For example
+ * hello(yourName) => Intl.message("Hello, $yourName",
+ * name: "hello",
+ * args: [name],
+ * desc: "Say hello",
+ * examples = {"yourName": "Sparky"}.
+ * The source code will be processed via the analyzer to extract out the
+ * message data, so only a subset of valid Dart code is accepted. In
+ * particular, everything must be literal and cannot refer to variables
+ * outside the scope of the enclosing function. The [examples] map must
+ * be valid JSON, which in addition to requiring only simple literals means
+ * that strings must use double-quotes exclusively and cannot use features
+ * like raw strings or concatenation. Similarly, the [desc] argument must
+ * be a single, simple string.
+ *
* The expected usage of this is inside a function that takes as parameters
- * the variables used in the interpolated string, and additionally also a
- * locale (optional).
- * Ultimately, the information about the enclosing function and its arguments
- * will be extracted automatically but for the time being it must be passed
- * explicitly in the [name] and [args] arguments.
+ * the variables used in the interpolated string, and an optional
+ * locale.
+ *
+ * The [name] and [args] arguments are required, and are used at runtime
+ * to look up the localized version and pass the appropriate arguments to it.
+ * We may in the future modify the code during compilation to make manually
+ * passing those arguments unnecessary.
*/
static String message(String message_str, {final String desc: '',
final Map examples: const {}, String locale, String name,
« no previous file with comments | « no previous file | pkg/intl/lib/src/intl_message.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698