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

Unified Diff: pkg/intl/test/message_extraction/generate_from_json.dart

Issue 183763026: Allow a single translation to be from multiple differently-named sources (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Re-upload Created 6 years, 10 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: pkg/intl/test/message_extraction/generate_from_json.dart
diff --git a/pkg/intl/test/message_extraction/generate_from_json.dart b/pkg/intl/test/message_extraction/generate_from_json.dart
index 320326c82fd4e335404d4ded40cd2ce2020a027b..c3ed80301a120af37b08abee24aa0c036526fb25 100644
--- a/pkg/intl/test/message_extraction/generate_from_json.dart
+++ b/pkg/intl/test/message_extraction/generate_from_json.dart
@@ -28,7 +28,7 @@ import 'package:serialization/serialization.dart';
* Keeps track of all the messages we have processed so far, keyed by message
* name.
*/
-Map<String, MainMessage> messages;
+Map<String, List<MainMessage>> messages;
main(List<String> args) {
var targetDir;
@@ -56,7 +56,8 @@ main(List<String> args) {
messages = new Map();
for (var eachMap in allMessages) {
- eachMap.forEach((key, value) => messages[key] = value);
+ eachMap.forEach((key, value) =>
+ messages.putIfAbsent(key, () => []).add(value));
}
for (var arg in jsonFiles) {
var file = new File(arg);
@@ -106,16 +107,16 @@ void generateLocaleFile(File file, String targetDir) {
/**
* A TranslatedMessage that just uses the name as the id and knows how to look
- * up its original message in our [messages].
+ * up its original messages in our [messages].
*/
class BasicTranslatedMessage extends TranslatedMessage {
BasicTranslatedMessage(String name, translated) :
super(name, translated);
- MainMessage get originalMessage =>
- (super.originalMessage == null) ? _findOriginal() : super.originalMessage;
+ List<MainMessage> get originalMessages => (super.originalMessages == null) ?
+ _findOriginals() : super.originalMessages;
// We know that our [id] is the name of the message, which is used as the
//key in [messages].
- MainMessage _findOriginal() => originalMessage = messages[id];
+ List<MainMessage> _findOriginals() => originalMessages = messages[id];
}

Powered by Google App Engine
This is Rietveld 408576698