No public description
PiperOrigin-RevId: 640927253
diff --git a/pkgs/intl_translation/test/message_extraction/make_hardcoded_translation.dart b/pkgs/intl_translation/test/message_extraction/make_hardcoded_translation.dart
index b83bd4c..5eea260 100644
--- a/pkgs/intl_translation/test/message_extraction/make_hardcoded_translation.dart
+++ b/pkgs/intl_translation/test/message_extraction/make_hardcoded_translation.dart
@@ -76,7 +76,14 @@
'literalDollar': 'Cinq sous est US\$0.05',
r"'<>{}= +-_$()&^%$#@!~`'": r"interessant (fr): '<>{}= +-_$()&^%$#@!~`'",
'extractable': 'Ce message devrait être extractible',
- 'skipMessageExistingTranslation': 'Ce message devrait ignorer la traduction'
+ 'skipMessageExistingTranslation': 'Ce message devrait ignorer la traduction',
+ 'noArgs': 'Ce message devrait ignorer la traduction',
+ 'noName': 'Ce message devrait ignorer la traduction',
+ 'badDescription': 'Ce message devrait ignorer la traduction',
+ 'noName:a': 'Ce message devrait ignorer la traduction',
+ 'thisNameIsAVariable': 'Ce message devrait ignorer la traduction',
+ 'noExamples': 'Ce message devrait ignorer la traduction',
+ 'badExamples': 'Ce message devrait ignorer la traduction',
};
// Used to test having translations in multiple files.
@@ -149,7 +156,14 @@
r"'<>{}= +-_$()&^%$#@!~`'": r"interessant (de): '<>{}= +-_$()&^%$#@!~`'",
'extractable': 'Diese Nachricht sollte extrahierbar sein',
'skipMessageExistingTranslation':
- 'Diese Nachricht sollte die Übersetzung überspringen'
+ 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'noArgs': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'noName': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'badDescription': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'noName:a': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'thisNameIsAVariable': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'noExamples': 'Diese Nachricht sollte die Übersetzung überspringen',
+ 'badExamples': 'Diese Nachricht sollte die Übersetzung überspringen',
};
/// The output directory for translated files.
diff --git a/pkgs/intl_translation/test/message_extraction/sample_with_messages.dart b/pkgs/intl_translation/test/message_extraction/sample_with_messages.dart
index 1c72d40..cbabb3b 100644
--- a/pkgs/intl_translation/test/message_extraction/sample_with_messages.dart
+++ b/pkgs/intl_translation/test/message_extraction/sample_with_messages.dart
@@ -205,6 +205,42 @@
skip: true,
desc: 'Skip with existing translation');
+// These messages are malformed and shouldn't be extracted.
+String noArgs(String x) => Intl.message('No arg for parameter: $x',
+ name: 'noArgs', desc: 'No args supplied', examples: const {'x': 3});
+
+String noName(String x) => Intl.message('noName: $x',
+ args: [x], desc: 'No name supplied', examples: const {'x': 3});
+
+String badName = 'thisNameIsAVariable';
+String nonLiteralName(String x) => Intl.message(
+ 'Non string literal name for '
+ 'message: $x',
+ name: badName,
+ args: [x],
+ desc: 'Non string literal name supplied',
+ examples: const {'x': 3});
+
+String wrongName(String x) => Intl.message('Wrong name for message: $x',
+ name: 'someOtherName',
+ desc: 'wrong name supplied',
+ examples: const {'x': 3});
+
+String badDescriptionString = 'thisDescriptionIsAVariable';
+String badDescription(String x) =>
+ Intl.message('Description must be a string literal: $x',
+ name: 'badArgs',
+ desc: badDescriptionString,
+ args: [x],
+ examples: const {'x': 3});
+
+String badExamples(String x) =>
+ Intl.message('Examples must be const literal map: $x',
+ name: 'badExamples',
+ desc: 'Examples must be const literal map.',
+ args: [x],
+ examples: {'x': 3});
+
void printStuff(Intl locale) {
// Use a name that's not a literal so this will get skipped. Then we have
// a name that's not in the original but we include it in the French
@@ -300,6 +336,12 @@
printOut(skipGender('female'));
printOut(skipSelect('Bob'));
printOut(skipMessageExistingTranslation());
+ printOut(noArgs('a'));
+ printOut(noName('a'));
+ printOut(nonLiteralName('a'));
+ printOut(wrongName('a'));
+ printOut(badDescription('a'));
+ printOut(badExamples('a'));
});
}
diff --git a/pkgs/intl_translation/test/message_extraction/verify_messages.dart b/pkgs/intl_translation/test/message_extraction/verify_messages.dart
index fbb268a..029888d 100644
--- a/pkgs/intl_translation/test/message_extraction/verify_messages.dart
+++ b/pkgs/intl_translation/test/message_extraction/verify_messages.dart
@@ -85,6 +85,12 @@
verify('Extraction skipped gender f');
verify('Extraction skipped select specified Bob!');
verify('This message should skip translation');
+ verify('No arg for parameter: a');
+ verify('noName: a');
+ verify('Non string literal name for message: a');
+ verify('Wrong name for message: a');
+ verify('Description must be a string literal: a');
+ verify('Examples must be const literal map: a');
verify('-------------------------------------------');
// French translations.
@@ -157,6 +163,12 @@
verify('Extraction skipped gender f');
verify('Extraction skipped select specified Bob!');
verify('This message should skip translation');
+ verify('No arg for parameter: a');
+ verify('noName: a');
+ verify('Non string literal name for message: a');
+ verify('Wrong name for message: a');
+ verify('Description must be a string literal: a');
+ verify('Examples must be const literal map: a');
verify('-------------------------------------------');
// German translations.
@@ -229,6 +241,12 @@
verify('Extraction skipped gender f');
verify('Extraction skipped select specified Bob!');
verify('This message should skip translation');
+ verify('No arg for parameter: a');
+ verify('noName: a');
+ verify('Non string literal name for message: a');
+ verify('Wrong name for message: a');
+ verify('Description must be a string literal: a');
+ verify('Examples must be const literal map: a');
if (lineIterator.moveNext()) {
throw 'more messages than expected';