mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Revert "[gen-l10n] Fixes named and positional parameter issue with NumberFormat when type is specified (#75209)" (#75306)
This reverts commit 917577b808
.
This commit is contained in:
parent
7b04422884
commit
c12b53e073
@ -146,24 +146,13 @@ String generateNumberFormattingLogic(Message message) {
|
||||
}
|
||||
final Iterable<String> parameters =
|
||||
placeholder.optionalParameters.map<String>((OptionalParameter parameter) {
|
||||
if (parameter.value is num) {
|
||||
return '${parameter.name}: ${parameter.value}';
|
||||
} else {
|
||||
return '${parameter.name}: ${generateString(parameter.value.toString())}';
|
||||
}
|
||||
return '${parameter.name}: ${parameter.value}';
|
||||
},
|
||||
);
|
||||
|
||||
if (placeholder.hasNumberFormatWithParameters) {
|
||||
return numberFormatNamedTemplate
|
||||
.replaceAll('@(placeholder)', placeholder.name)
|
||||
.replaceAll('@(format)', placeholder.format)
|
||||
.replaceAll('@(parameters)', parameters.join(',\n '));
|
||||
} else {
|
||||
return numberFormatPositionalTemplate
|
||||
.replaceAll('@(placeholder)', placeholder.name)
|
||||
.replaceAll('@(format)', placeholder.format);
|
||||
}
|
||||
return numberFormatTemplate
|
||||
.replaceAll('@(placeholder)', placeholder.name)
|
||||
.replaceAll('@(format)', placeholder.format)
|
||||
.replaceAll('@(parameters)', parameters.join(', \n'));
|
||||
});
|
||||
|
||||
return formatStatements.isEmpty ? '@(none)' : formatStatements.join('');
|
||||
|
@ -112,12 +112,7 @@ abstract class @(class) {
|
||||
@(delegateClass)
|
||||
''';
|
||||
|
||||
const String numberFormatPositionalTemplate = '''
|
||||
final intl.NumberFormat @(placeholder)NumberFormat = intl.NumberFormat.@(format)(localeName);
|
||||
final String @(placeholder)String = @(placeholder)NumberFormat.format(@(placeholder));
|
||||
''';
|
||||
|
||||
const String numberFormatNamedTemplate = '''
|
||||
const String numberFormatTemplate = '''
|
||||
final intl.NumberFormat @(placeholder)NumberFormat = intl.NumberFormat.@(format)(
|
||||
locale: localeName,
|
||||
@(parameters)
|
||||
|
@ -92,66 +92,59 @@ void main() {
|
||||
'#l10n 37 (Hello World from 1960 to 2020)\n'
|
||||
'#l10n 38 (Hello for 123)\n'
|
||||
'#l10n 39 (Hello for price USD123.00)\n'
|
||||
'#l10n 40 (Hello for price BTC0.50 (with optional param))\n'
|
||||
'#l10n 41 (Hello for price BTC\'0.50 (with special character))\n'
|
||||
'#l10n 42 (Hello for price BTC"0.50 (with special character))\n'
|
||||
'#l10n 43 (Hello for price BTC"\'0.50 (with special character))\n'
|
||||
'#l10n 44 (Hello for Decimal Pattern 1,200,000)\n'
|
||||
'#l10n 45 (Hello for Percent Pattern 120,000,000%)\n'
|
||||
'#l10n 46 (Hello for Scientific Pattern 1E6)\n'
|
||||
'#l10n 47 (Hello)\n'
|
||||
'#l10n 48 (Hello World)\n'
|
||||
'#l10n 49 (Hello two worlds)\n'
|
||||
'#l10n 50 (Hello)\n'
|
||||
'#l10n 51 (Hello new World)\n'
|
||||
'#l10n 52 (Hello two new worlds)\n'
|
||||
'#l10n 53 (Hello on Friday, January 1, 1960)\n'
|
||||
'#l10n 54 (Hello World, on Friday, January 1, 1960)\n'
|
||||
'#l10n 55 (Hello two worlds, on Friday, January 1, 1960)\n'
|
||||
'#l10n 56 (Hello other 0 worlds, with a total of 100 citizens)\n'
|
||||
'#l10n 57 (Hello World of 101 citizens)\n'
|
||||
'#l10n 58 (Hello two worlds with 102 total citizens)\n'
|
||||
'#l10n 59 ([Hello] -World- #123#)\n'
|
||||
'#l10n 60 (\$!)\n'
|
||||
'#l10n 61 (One \$)\n'
|
||||
'#l10n 62 (Flutter\'s amazing!)\n'
|
||||
'#l10n 63 (Flutter\'s amazing, times 2!)\n'
|
||||
'#l10n 64 (Flutter is "amazing"!)\n'
|
||||
'#l10n 65 (Flutter is "amazing", times 2!)\n'
|
||||
'#l10n 66 (--- es ---)\n'
|
||||
'#l10n 67 (ES - Hello world)\n'
|
||||
'#l10n 68 (ES - Hello _NEWLINE_ World)\n'
|
||||
'#l10n 69 (ES - Hola \$ Mundo)\n'
|
||||
'#l10n 70 (ES - Hello Mundo)\n'
|
||||
'#l10n 71 (ES - Hola Mundo)\n'
|
||||
'#l10n 72 (ES - Hello World on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 73 (ES - Hello world argument on 1/1/1960 at 0:00)\n'
|
||||
'#l10n 74 (ES - Hello World from 1960 to 2020)\n'
|
||||
'#l10n 75 (ES - Hello for 123)\n'
|
||||
'#l10n 76 (ES - Hello)\n'
|
||||
'#l10n 77 (ES - Hello World)\n'
|
||||
'#l10n 78 (ES - Hello two worlds)\n'
|
||||
'#l10n 79 (ES - Hello)\n'
|
||||
'#l10n 80 (ES - Hello nuevo World)\n'
|
||||
'#l10n 81 (ES - Hello two nuevo worlds)\n'
|
||||
'#l10n 82 (ES - Hello on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 83 (ES - Hello World, o n viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 84 (ES - Hello two worlds, on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 85 (ES - Hello other 0 worlds, with a total of 100 citizens)\n'
|
||||
'#l10n 86 (ES - Hello World of 101 citizens)\n'
|
||||
'#l10n 87 (ES - Hello two worlds with 102 total citizens)\n'
|
||||
'#l10n 88 (ES - [Hola] -Mundo- #123#)\n'
|
||||
'#l10n 89 (ES - \$!)\n'
|
||||
'#l10n 90 (ES - One \$)\n'
|
||||
'#l10n 91 (ES - Flutter\'s amazing!)\n'
|
||||
'#l10n 92 (ES - Flutter\'s amazing, times 2!)\n'
|
||||
'#l10n 93 (ES - Flutter is "amazing"!)\n'
|
||||
'#l10n 94 (ES - Flutter is "amazing", times 2!)\n'
|
||||
'#l10n 95 (--- es_419 ---)\n'
|
||||
'#l10n 96 (ES 419 - Hello World)\n'
|
||||
'#l10n 97 (ES 419 - Hello)\n'
|
||||
'#l10n 98 (ES 419 - Hello World)\n'
|
||||
'#l10n 99 (ES 419 - Hello two worlds)\n'
|
||||
'#l10n 40 (Hello)\n'
|
||||
'#l10n 41 (Hello World)\n'
|
||||
'#l10n 42 (Hello two worlds)\n'
|
||||
'#l10n 43 (Hello)\n'
|
||||
'#l10n 44 (Hello new World)\n'
|
||||
'#l10n 45 (Hello two new worlds)\n'
|
||||
'#l10n 46 (Hello on Friday, January 1, 1960)\n'
|
||||
'#l10n 47 (Hello World, on Friday, January 1, 1960)\n'
|
||||
'#l10n 48 (Hello two worlds, on Friday, January 1, 1960)\n'
|
||||
'#l10n 49 (Hello other 0 worlds, with a total of 100 citizens)\n'
|
||||
'#l10n 50 (Hello World of 101 citizens)\n'
|
||||
'#l10n 51 (Hello two worlds with 102 total citizens)\n'
|
||||
'#l10n 52 ([Hello] -World- #123#)\n'
|
||||
'#l10n 53 (\$!)\n'
|
||||
'#l10n 54 (One \$)\n'
|
||||
'#l10n 55 (Flutter\'s amazing!)\n'
|
||||
'#l10n 56 (Flutter\'s amazing, times 2!)\n'
|
||||
'#l10n 57 (Flutter is "amazing"!)\n'
|
||||
'#l10n 58 (Flutter is "amazing", times 2!)\n'
|
||||
'#l10n 59 (--- es ---)\n'
|
||||
'#l10n 60 (ES - Hello world)\n'
|
||||
'#l10n 61 (ES - Hello _NEWLINE_ World)\n'
|
||||
'#l10n 62 (ES - Hola \$ Mundo)\n'
|
||||
'#l10n 63 (ES - Hello Mundo)\n'
|
||||
'#l10n 64 (ES - Hola Mundo)\n'
|
||||
'#l10n 65 (ES - Hello World on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 66 (ES - Hello world argument on 1/1/1960 at 0:00)\n'
|
||||
'#l10n 67 (ES - Hello World from 1960 to 2020)\n'
|
||||
'#l10n 68 (ES - Hello for 123)\n'
|
||||
'#l10n 69 (ES - Hello)\n'
|
||||
'#l10n 70 (ES - Hello World)\n'
|
||||
'#l10n 71 (ES - Hello two worlds)\n'
|
||||
'#l10n 72 (ES - Hello)\n'
|
||||
'#l10n 73 (ES - Hello nuevo World)\n'
|
||||
'#l10n 74 (ES - Hello two nuevo worlds)\n'
|
||||
'#l10n 75 (ES - Hello on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 76 (ES - Hello World, on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 77 (ES - Hello two worlds, on viernes, 1 de enero de 1960)\n'
|
||||
'#l10n 78 (ES - Hello other 0 worlds, with a total of 100 citizens)\n'
|
||||
'#l10n 79 (ES - Hello World of 101 citizens)\n'
|
||||
'#l10n 80 (ES - Hello two worlds with 102 total citizens)\n'
|
||||
'#l10n 81 (ES - [Hola] -Mundo- #123#)\n'
|
||||
'#l10n 82 (ES - \$!)\n'
|
||||
'#l10n 83 (ES - One \$)\n'
|
||||
'#l10n 84 (ES - Flutter\'s amazing!)\n'
|
||||
'#l10n 85 (ES - Flutter\'s amazing, times 2!)\n'
|
||||
'#l10n 86 (ES - Flutter is "amazing"!)\n'
|
||||
'#l10n 87 (ES - Flutter is "amazing", times 2!)\n'
|
||||
'#l10n 88 (--- es_419 ---)\n'
|
||||
'#l10n 89 (ES 419 - Hello World)\n'
|
||||
'#l10n 90 (ES 419 - Hello)\n'
|
||||
'#l10n 91 (ES 419 - Hello World)\n'
|
||||
'#l10n 92 (ES 419 - Hello two worlds)\n'
|
||||
'#l10n END\n'
|
||||
);
|
||||
}
|
||||
|
@ -199,13 +199,6 @@ class Home extends StatelessWidget {
|
||||
'${localizations.helloWorldDuring(DateTime(1960), DateTime(2020))}',
|
||||
'${localizations.helloFor(123)}',
|
||||
'${localizations.helloCost("price", 123)}',
|
||||
'${localizations.helloCostWithOptionalParam("price", .5)}',
|
||||
'${localizations.helloCostWithSpecialCharacter1("price", .5)}',
|
||||
'${localizations.helloCostWithSpecialCharacter2("price", .5)}',
|
||||
'${localizations.helloCostWithSpecialCharacter3("price", .5)}',
|
||||
'${localizations.helloDecimalPattern(1200000)}',
|
||||
'${localizations.helloPercentPattern(1200000)}',
|
||||
'${localizations.helloScientificPattern(1200000)}',
|
||||
'${localizations.helloWorlds(0)}',
|
||||
'${localizations.helloWorlds(1)}',
|
||||
'${localizations.helloWorlds(2)}',
|
||||
@ -418,99 +411,6 @@ void main() {
|
||||
}
|
||||
},
|
||||
|
||||
"helloCostWithOptionalParam": "Hello for {price} {value} (with optional param)",
|
||||
"@helloCostWithOptionalParam": {
|
||||
"description": "A message with string and int (currency) parameters",
|
||||
"placeholders": {
|
||||
"price": {},
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "currency",
|
||||
"optionalParameters": {
|
||||
"name": "BTC"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloCostWithSpecialCharacter1": "Hello for {price} {value} (with special character)",
|
||||
"@helloCostWithSpecialCharacter1": {
|
||||
"description": "A message with string and int (currency) parameters",
|
||||
"placeholders": {
|
||||
"price": {},
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "currency",
|
||||
"optionalParameters": {
|
||||
"name": "BTC'"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloCostWithSpecialCharacter2": "Hello for {price} {value} (with special character)",
|
||||
"@helloCostWithSpecialCharacter2": {
|
||||
"description": "A message with string and int (currency) parameters",
|
||||
"placeholders": {
|
||||
"price": {},
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "currency",
|
||||
"optionalParameters": {
|
||||
"name": "BTC\""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloCostWithSpecialCharacter3": "Hello for {price} {value} (with special character)",
|
||||
"@helloCostWithSpecialCharacter3": {
|
||||
"description": "A message with string and int (currency) parameters",
|
||||
"placeholders": {
|
||||
"price": {},
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "currency",
|
||||
"optionalParameters": {
|
||||
"name": "BTC\"'"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloDecimalPattern": "Hello for Decimal Pattern {value}",
|
||||
"@helloDecimalPattern": {
|
||||
"description": "A message which displays a number in decimal pattern",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "decimalPattern"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloPercentPattern": "Hello for Percent Pattern {value}",
|
||||
"@helloPercentPattern": {
|
||||
"description": "A message which displays a number in percent pattern",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "percentPattern"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloScientificPattern": "Hello for Scientific Pattern {value}",
|
||||
"@helloScientificPattern": {
|
||||
"description": "A message which displays scientific notation of a number",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "double",
|
||||
"format": "scientificPattern"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"helloWorlds": "{count,plural, =0{Hello} =1{Hello World} =2{Hello two worlds} few{Hello {count} worlds} many{Hello all {count} worlds} other{Hello other {count} worlds}}",
|
||||
"@helloWorlds": {
|
||||
"description": "A plural message",
|
||||
|
Loading…
Reference in New Issue
Block a user