gen_l10n: generated Intl.message parameter should be an ordinary string (#48929)

This commit is contained in:
Hans Muller
2020-01-16 07:20:38 -08:00
committed by GitHub
parent c51059f84c
commit 667c38d551
2 changed files with 12 additions and 10 deletions

View File

@@ -456,18 +456,20 @@ String genSimpleMethod(Map<String, dynamic> arbBundle, String resourceId) {
);
if (attributesMap.containsKey('placeholders')) {
final String rawMessageString = genSimpleMethodMessage(arbBundle, resourceId); // "r'...'"
return simpleMethodTemplate
.replaceAll('@methodName', resourceId)
.replaceAll('@methodParameters', genMethodParameters(arbBundle, resourceId, 'Object').join(', '))
.replaceAll('@dateFormatting', generateDateFormattingLogic(arbBundle, resourceId))
.replaceAll('@numberFormatting', generateNumberFormattingLogic(arbBundle, resourceId))
.replaceAll('@message', '${genSimpleMethodMessage(arbBundle, resourceId)}')
.replaceAll('@message', '${rawMessageString.substring(1)}')
.replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n '));
}
final String rawMessageString = generateString(arbBundle[resourceId] as String); // "r'...'"
return getterMethodTemplate
.replaceAll('@methodName', resourceId)
.replaceAll('@message', '${generateString(arbBundle[resourceId] as String)}')
.replaceAll('@message', '${rawMessageString.substring(1)}')
.replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n '));
}

View File

@@ -611,7 +611,7 @@ void main() {
generator.classMethods.first,
''' String get title {
return Intl.message(
r'Title',
'Title',
locale: _localeName,
name: 'title',
desc: r'Title for the application'
@@ -656,7 +656,7 @@ void main() {
generator.classMethods.first,
''' String itemNumber(Object value) {
return Intl.message(
r\'Item \$value\',
\'Item \$value\',
locale: _localeName,
name: 'itemNumber',
desc: r\'Item placement in list.\',
@@ -707,7 +707,7 @@ void main() {
final String springStartDateString = springStartDateDateFormat.format(springStartDate);
return Intl.message(
r'Spring begins on \$springStartDateString',
'Spring begins on \$springStartDateString',
locale: _localeName,
name: 'springBegins',
desc: r'The first day of spring',
@@ -831,7 +831,7 @@ void main() {
final String springStartDateString = springStartDateDateFormat.format(springStartDate);
return Intl.message(
r\'Since it\' "\'" r\'s \$springStartDateString, it\' "\'" r\'s finally spring! \$helloWorld!\',
\'Since it\' "\'" r\'s \$springStartDateString, it\' "\'" r\'s finally spring! \$helloWorld!\',
locale: _localeName,
name: 'springGreetings',
desc: r\'A realization that it\' "\'" r\'s finally the spring season, followed by a greeting.\',
@@ -888,7 +888,7 @@ void main() {
final String springEndDateString = springEndDateDateFormat.format(springEndDate);
return Intl.message(
r\'Spring begins on \$springStartDateString and ends on \$springEndDateString\',
\'Spring begins on \$springStartDateString and ends on \$springEndDateString\',
locale: _localeName,
name: 'springRange',
desc: r\'The range of dates for spring in the year\',
@@ -996,7 +996,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress);
return Intl.message(
r'You have completed \$progressString of the course.',
'You have completed \$progressString of the course.',
locale: _localeName,
name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.',
@@ -1063,7 +1063,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress);
return Intl.message(
r'You have completed \$progressString of the course.',
'You have completed \$progressString of the course.',
locale: _localeName,
name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.',
@@ -1121,7 +1121,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress);
return Intl.message(
r'You have completed \$progressString of the course.',
'You have completed \$progressString of the course.',
locale: _localeName,
name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.',