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

Unified Diff: pkg/intl/lib/generate_localized.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
« no previous file with comments | « no previous file | pkg/intl/test/message_extraction/foo_messages_all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/generate_localized.dart
diff --git a/pkg/intl/lib/generate_localized.dart b/pkg/intl/lib/generate_localized.dart
index b5ccd2824fa25d2cd1ec35ea1b1fffca638894ac..457f7c78b522bc6c3f46be6959cc55dd97603dc2 100644
--- a/pkg/intl/lib/generate_localized.dart
+++ b/pkg/intl/lib/generate_localized.dart
@@ -68,11 +68,20 @@ abstract class TranslatedMessage {
*/
final String id;
- /** Our translated version of [originalMessage]. */
+ /** Our translated version of all the [originalMessages]. */
final Message translated;
- /** The original message that we are a translation of. */
- MainMessage originalMessage;
+ /**
+ * The original messages that we are a translation of. There can
+ * be more than one original message for the same translation.
+ */
+ List<MainMessage> originalMessages;
+
+ /**
+ * For backward compatibility, we still have the originalMessage API.
+ */
+ MainMessage get originalMessage => originalMessages.first;
+ set originalMessage(MainMessage m) => originalMessages = [m];
TranslatedMessage(this.id, this.translated);
@@ -99,21 +108,26 @@ void generateIndividualMessageFile(String locale,
// Exclude messages with no translation and translations with no matching
// original message (e.g. if we're using some messages from a larger catalog)
var usableTranslations = translations.where(
- (each) => each.originalMessage != null && each.message != null).toList();
+ (each) => each.originalMessages != null && each.message != null).toList();
for (var each in usableTranslations) {
- each.originalMessage.addTranslation(locale, each.message);
+ for (var original in each.originalMessages) {
+ original.addTranslation(locale, each.message);
+ }
}
usableTranslations.sort((a, b) =>
- a.originalMessage.name.compareTo(b.originalMessage.name));
+ a.originalMessages.first.name.compareTo(b.originalMessages.first.name));
for (var translation in usableTranslations) {
- result
- ..write(" ")
- ..write(translation.originalMessage.toCodeForLocale(locale))
- ..write("\n\n");
+ for (var original in translation.originalMessages) {
+ result
+ ..write(" ")
+ ..write(original.toCodeForLocale(locale))
+ ..write("\n\n");
+ }
}
result.write("\n final messages = const {\n");
var entries = usableTranslations
- .map((translation) => translation.originalMessage.name)
+ .expand((translation) => translation.originalMessages)
+ .map((original) => original.name)
.map((name) => " \"$name\" : $name");
result
..write(entries.join(",\n"))
« no previous file with comments | « no previous file | pkg/intl/test/message_extraction/foo_messages_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698