Unverified Commit eb185d73 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by GitHub

internationalization: fix select with incorrect message (#90096)

parent cd1892f0
......@@ -300,6 +300,11 @@ String _generateSelectMethod(Message message, String translationForMessage) {
);
}
}
} else {
throw L10nException(
'Incorrect select message format for: ${message.resourceId}.\n'
'Check to see if the select message is in the proper ICU syntax format.'
);
}
final List<String> parameters = message.placeholders.map((Placeholder placeholder) {
......
......@@ -1909,6 +1909,46 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
)),
);
});
testWithoutContext('should throw attempting to generate a select message with an incorrect message', () {
const String selectMessageWithoutPlaceholdersAttribute = '''
{
"genderSelect": "{gender, select,}",
"@genderSelect": {
"placeholders": {
"gender": {}
}
}
}''';
final Directory l10nDirectory = fs.currentDirectory.childDirectory('lib').childDirectory('l10n')
..createSync(recursive: true);
l10nDirectory.childFile(defaultTemplateArbFileName)
.writeAsStringSync(selectMessageWithoutPlaceholdersAttribute);
expect(
() {
LocalizationsGenerator(
fileSystem: fs,
inputPathString: defaultL10nPathString,
outputPathString: defaultL10nPathString,
templateArbFileName: defaultTemplateArbFileName,
outputFileString: defaultOutputFileString,
classNameString: defaultClassNameString,
)
..loadResources()
..writeOutputFiles(BufferLogger.test());
},
throwsA(isA<L10nException>().having(
(L10nException e) => e.message,
'message',
allOf(
contains('Incorrect select message format for'),
contains('Check to see if the select message is in the proper ICU syntax format.'),
),
)),
);
});
});
testWithoutContext('intl package import should be omitted in subclass files when no plurals are included', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment