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

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

Issue 23449021: Allow creating VariableSubstitution by name or by index (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/src/intl_message.dart
diff --git a/pkg/intl/lib/src/intl_message.dart b/pkg/intl/lib/src/intl_message.dart
index ad88395a9ad6e72f7c70ea3bb4ee80d3929779a8..0eb67b13846541ee944d4f52931c26a93d4f9e72 100644
--- a/pkg/intl/lib/src/intl_message.dart
+++ b/pkg/intl/lib/src/intl_message.dart
@@ -233,14 +233,22 @@ class LiteralString extends Message {
/**
* Represents an interpolation of a variable value in a message. We expect
- * this to be specified as an [index] into the list of variables, and we will
- * compute the variable name for the interpolation based on that.
+ * this to be specified as an [index] into the list of variables, or else
+ * as the name of a variable that exists in [arguments] and we will
+ * compute the variable name or the index based on the value of the other.
*/
class VariableSubstitution extends Message {
- VariableSubstitution(this.index, Message parent) : super(parent);
+ VariableSubstitution(this._index, Message parent) : super(parent);
+ VariableSubstitution.named(this._variableName, Message parent)
+ : super(parent);
/** The index in the list of parameters of the containing function. */
- int index;
+ int _index;
+ int get index {
+ if (_index != null) return _index;
+ if (arguments.isEmpty) return null;
+ return _index = arguments.indexOf(_variableName);
+ }
/**
* The name of the variable in the parameter list of the containing function.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698