mirror of
https://github.com/flutter/flutter
synced 2024-10-12 19:23:02 +00:00
internationalization: fix select with incorrect message (#90096)
This commit is contained in:
parent
cd1892f04f
commit
eb185d73ce
|
@ -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) {
|
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', () {
|
testWithoutContext('intl package import should be omitted in subclass files when no plurals are included', () {
|
||||||
|
|
Loading…
Reference in a new issue