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

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

Issue 18543009: Plurals and Genders (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo 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/lib/intl.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 f6a42254eff6bf1cbc30f94259985e2e41c07686..d99faa1801fb46d775f738f28918ede161358c0a 100644
--- a/pkg/intl/lib/generate_localized.dart
+++ b/pkg/intl/lib/generate_localized.dart
@@ -61,14 +61,25 @@ String generatedFilePrefix = '';
* mechanisms are expected to subclass this.
*/
abstract class TranslatedMessage {
- /** The identifier for this message. In the simplest case, this is the name.*/
- var id;
+ /**
+ * The identifier for this message. In the simplest case, this is the name
+ * parameter from the Intl.message call,
+ * but it can be any identifier that this program and the output of the
+ * translation can agree on as identifying a message.
+ */
+ String id;
- String translatedString;
- IntlMessage originalMessage;
- TranslatedMessage(this.id, this.translatedString);
+ /** Our translated version of [originalMessage]. */
+ Message translated;
- String get message => translatedString;
+ /** The original message that we are a translation of. */
+ MainMessage originalMessage;
+
+ TranslatedMessage(this.id, this.translated);
+
+ Message get message => translated;
+
+ toString() => id.toString();
}
/**
@@ -78,13 +89,13 @@ abstract class TranslatedMessage {
String asLibraryName(String x) => x.replaceAll('-', '_');
/**
- * Generate a file messages_<locale>.dart for the [translations] in
- * [locale].
+ * Generate a file <[generated_file_prefix]>_messages_<[locale]>.dart
+ * for the [translations] in [locale] and put it in [targetDir].
*/
void generateIndividualMessageFile(String locale,
Iterable<TranslatedMessage> translations, String targetDir) {
var result = new StringBuffer();
- locale = new IntlMessage().escapeAndValidate(locale, locale);
+ locale = new MainMessage().escapeAndValidateString(locale);
result.write(prologue(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)
@@ -95,9 +106,9 @@ void generateIndividualMessageFile(String locale,
}
usableTranslations.sort((a, b) =>
a.originalMessage.name.compareTo(b.originalMessage.name));
- for (var each in usableTranslations) {
+ for (var translation in usableTranslations) {
result.write(" ");
- result.write(each.originalMessage.toCode(locale));
+ result.write(translation.originalMessage.toCodeForLocale(locale));
result.write("\n\n");
}
result.write("\n final messages = const {\n");
« no previous file with comments | « pkg/intl/lib/extract_messages.dart ('k') | pkg/intl/lib/intl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698