Unverified Commit 667c38d5 authored by Hans Muller's avatar Hans Muller Committed by GitHub

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

parent c51059f8
...@@ -456,18 +456,20 @@ String genSimpleMethod(Map<String, dynamic> arbBundle, String resourceId) { ...@@ -456,18 +456,20 @@ String genSimpleMethod(Map<String, dynamic> arbBundle, String resourceId) {
); );
if (attributesMap.containsKey('placeholders')) { if (attributesMap.containsKey('placeholders')) {
final String rawMessageString = genSimpleMethodMessage(arbBundle, resourceId); // "r'...'"
return simpleMethodTemplate return simpleMethodTemplate
.replaceAll('@methodName', resourceId) .replaceAll('@methodName', resourceId)
.replaceAll('@methodParameters', genMethodParameters(arbBundle, resourceId, 'Object').join(', ')) .replaceAll('@methodParameters', genMethodParameters(arbBundle, resourceId, 'Object').join(', '))
.replaceAll('@dateFormatting', generateDateFormattingLogic(arbBundle, resourceId)) .replaceAll('@dateFormatting', generateDateFormattingLogic(arbBundle, resourceId))
.replaceAll('@numberFormatting', generateNumberFormattingLogic(arbBundle, resourceId)) .replaceAll('@numberFormatting', generateNumberFormattingLogic(arbBundle, resourceId))
.replaceAll('@message', '${genSimpleMethodMessage(arbBundle, resourceId)}') .replaceAll('@message', '${rawMessageString.substring(1)}')
.replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n ')); .replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n '));
} }
final String rawMessageString = generateString(arbBundle[resourceId] as String); // "r'...'"
return getterMethodTemplate return getterMethodTemplate
.replaceAll('@methodName', resourceId) .replaceAll('@methodName', resourceId)
.replaceAll('@message', '${generateString(arbBundle[resourceId] as String)}') .replaceAll('@message', '${rawMessageString.substring(1)}')
.replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n ')); .replaceAll('@intlMethodArgs', genIntlMethodArgs(arbBundle, resourceId).join(',\n '));
} }
......
...@@ -611,7 +611,7 @@ void main() { ...@@ -611,7 +611,7 @@ void main() {
generator.classMethods.first, generator.classMethods.first,
''' String get title { ''' String get title {
return Intl.message( return Intl.message(
r'Title', 'Title',
locale: _localeName, locale: _localeName,
name: 'title', name: 'title',
desc: r'Title for the application' desc: r'Title for the application'
...@@ -656,7 +656,7 @@ void main() { ...@@ -656,7 +656,7 @@ void main() {
generator.classMethods.first, generator.classMethods.first,
''' String itemNumber(Object value) { ''' String itemNumber(Object value) {
return Intl.message( return Intl.message(
r\'Item \$value\', \'Item \$value\',
locale: _localeName, locale: _localeName,
name: 'itemNumber', name: 'itemNumber',
desc: r\'Item placement in list.\', desc: r\'Item placement in list.\',
...@@ -707,7 +707,7 @@ void main() { ...@@ -707,7 +707,7 @@ void main() {
final String springStartDateString = springStartDateDateFormat.format(springStartDate); final String springStartDateString = springStartDateDateFormat.format(springStartDate);
return Intl.message( return Intl.message(
r'Spring begins on \$springStartDateString', 'Spring begins on \$springStartDateString',
locale: _localeName, locale: _localeName,
name: 'springBegins', name: 'springBegins',
desc: r'The first day of spring', desc: r'The first day of spring',
...@@ -831,7 +831,7 @@ void main() { ...@@ -831,7 +831,7 @@ void main() {
final String springStartDateString = springStartDateDateFormat.format(springStartDate); final String springStartDateString = springStartDateDateFormat.format(springStartDate);
return Intl.message( 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, locale: _localeName,
name: 'springGreetings', name: 'springGreetings',
desc: r\'A realization that it\' "\'" r\'s finally the spring season, followed by a greeting.\', desc: r\'A realization that it\' "\'" r\'s finally the spring season, followed by a greeting.\',
...@@ -888,7 +888,7 @@ void main() { ...@@ -888,7 +888,7 @@ void main() {
final String springEndDateString = springEndDateDateFormat.format(springEndDate); final String springEndDateString = springEndDateDateFormat.format(springEndDate);
return Intl.message( return Intl.message(
r\'Spring begins on \$springStartDateString and ends on \$springEndDateString\', \'Spring begins on \$springStartDateString and ends on \$springEndDateString\',
locale: _localeName, locale: _localeName,
name: 'springRange', name: 'springRange',
desc: r\'The range of dates for spring in the year\', desc: r\'The range of dates for spring in the year\',
...@@ -996,7 +996,7 @@ void main() { ...@@ -996,7 +996,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress); final String progressString = progressNumberFormat.format(progress);
return Intl.message( return Intl.message(
r'You have completed \$progressString of the course.', 'You have completed \$progressString of the course.',
locale: _localeName, locale: _localeName,
name: 'courseCompletion', name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.', desc: r'The amount of progress the student has made in their class.',
...@@ -1063,7 +1063,7 @@ void main() { ...@@ -1063,7 +1063,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress); final String progressString = progressNumberFormat.format(progress);
return Intl.message( return Intl.message(
r'You have completed \$progressString of the course.', 'You have completed \$progressString of the course.',
locale: _localeName, locale: _localeName,
name: 'courseCompletion', name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.', desc: r'The amount of progress the student has made in their class.',
...@@ -1121,7 +1121,7 @@ void main() { ...@@ -1121,7 +1121,7 @@ void main() {
final String progressString = progressNumberFormat.format(progress); final String progressString = progressNumberFormat.format(progress);
return Intl.message( return Intl.message(
r'You have completed \$progressString of the course.', 'You have completed \$progressString of the course.',
locale: _localeName, locale: _localeName,
name: 'courseCompletion', name: 'courseCompletion',
desc: r'The amount of progress the student has made in their class.', desc: r'The amount of progress the student has made in their class.',
......
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