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

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

Issue 17113002: Allow translated messages that have no matching original message (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a typo in help text Created 7 years, 6 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 | « pkg/intl/lib/extract_messages.dart ('k') | pkg/intl/test/message_extraction/extract_to_json.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 c40d1f64705f6e985abef5ae5ed996ae67e1520f..f6a42254eff6bf1cbc30f94259985e2e41c07686 100644
--- a/pkg/intl/lib/generate_localized.dart
+++ b/pkg/intl/lib/generate_localized.dart
@@ -86,22 +86,22 @@ void generateIndividualMessageFile(String locale,
var result = new StringBuffer();
locale = new IntlMessage().escapeAndValidate(locale, locale);
result.write(prologue(locale));
- for (var each in translations) {
- var message = each.originalMessage;
- if (each.message != null) {
- message.addTranslation(locale, each.message);
- }
+ // 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();
+ for (var each in usableTranslations) {
+ each.originalMessage.addTranslation(locale, each.message);
}
- var sorted = translations.where((each) => each.message != null).toList();
- sorted.sort((a, b) =>
+ usableTranslations.sort((a, b) =>
a.originalMessage.name.compareTo(b.originalMessage.name));
- for (var each in sorted) {
+ for (var each in usableTranslations) {
result.write(" ");
result.write(each.originalMessage.toCode(locale));
result.write("\n\n");
}
result.write("\n final messages = const {\n");
- var entries = sorted
+ var entries = usableTranslations
.map((translation) => translation.originalMessage.name)
.map((name) => " \"$name\" : $name");
result.write(entries.join(",\n"));
« no previous file with comments | « pkg/intl/lib/extract_messages.dart ('k') | pkg/intl/test/message_extraction/extract_to_json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698