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

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

Issue 23934007: Handle reading upper-case placeholders (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 0eb67b13846541ee944d4f52931c26a93d4f9e72..2fe5fd021de16a923d3f0dda53821454adf74903 100644
--- a/pkg/intl/lib/src/intl_message.dart
+++ b/pkg/intl/lib/src/intl_message.dart
@@ -239,18 +239,37 @@ class LiteralString extends Message {
*/
class VariableSubstitution extends Message {
VariableSubstitution(this._index, Message parent) : super(parent);
- VariableSubstitution.named(this._variableName, Message parent)
- : super(parent);
+
+ /**
+ * Create a substitution based on the name rather than the index. The name
Emily Fortuna 2013/09/12 00:52:19 yay, comments!
+ * may have been used as all upper-case in the translation tool, so we
+ * save it separately and look it up case-insensitively once the parent
+ * (and its arguments) are definitely available.
+ */
+ VariableSubstitution.named(String name, Message parent)
+ : super(parent) {
+ _variableNameUpper = name.toUpperCase();
+ }
/** The index in the list of parameters of the containing function. */
int _index;
int get index {
if (_index != null) return _index;
if (arguments.isEmpty) return null;
- return _index = arguments.indexOf(_variableName);
+ // We may have been given an all-uppercase version of the name, so compare
+ // case-insensitive.
+ _index = arguments.map((x) => x.toUpperCase()).toList()
+ .indexOf(_variableNameUpper);
+ return _index;
}
/**
+ * The variable name we get from parsing. This may be an all uppercase version
+ * of the Dart argument name.
+ */
+ String _variableNameUpper;
+
+ /**
* The name of the variable in the parameter list of the containing function.
* Used when generating code for the interpolation.
*/
« 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