[gen_l10n] Support plurals and selects inside string (#86167)

This commit is contained in:
Ahmed Ashour
2021-07-21 21:41:06 +02:00
committed by GitHub
parent b6419e8e89
commit f568d929db
6 changed files with 811 additions and 574 deletions

View File

@@ -118,40 +118,50 @@ void main() {
"#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, on 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 66 (16 wheel truck)\n'
"#l10n 67 (Sedan's elegance)\n"
'#l10n 68 (Cabriolet has "acceleration")\n'
'#l10n 69 (Oh, she found 1 item!)\n'
'#l10n 70 (Indeed, they like Flutter!)\n'
'#l10n 71 (--- es ---)\n'
'#l10n 72 (ES - Hello world)\n'
'#l10n 73 (ES - Hello _NEWLINE_ World)\n'
'#l10n 74 (ES - Hola \$ Mundo)\n'
'#l10n 75 (ES - Hello Mundo)\n'
'#l10n 76 (ES - Hola Mundo)\n'
'#l10n 77 (ES - Hello World on viernes, 1 de enero de 1960)\n'
'#l10n 78 (ES - Hello world argument on 1/1/1960 at 0:00)\n'
'#l10n 79 (ES - Hello World from 1960 to 2020)\n'
'#l10n 80 (ES - Hello for 123)\n'
'#l10n 81 (ES - Hello)\n'
'#l10n 82 (ES - Hello World)\n'
'#l10n 83 (ES - Hello two worlds)\n'
'#l10n 84 (ES - Hello)\n'
'#l10n 85 (ES - Hello nuevo World)\n'
'#l10n 86 (ES - Hello two nuevo worlds)\n'
'#l10n 87 (ES - Hello on viernes, 1 de enero de 1960)\n'
'#l10n 88 (ES - Hello World, on viernes, 1 de enero de 1960)\n'
'#l10n 89 (ES - Hello two worlds, on viernes, 1 de enero de 1960)\n'
'#l10n 90 (ES - Hello other 0 worlds, with a total of 100 citizens)\n'
'#l10n 91 (ES - Hello World of 101 citizens)\n'
'#l10n 92 (ES - Hello two worlds with 102 total citizens)\n'
'#l10n 93 (ES - [Hola] -Mundo- #123#)\n'
'#l10n 94 (ES - \$!)\n'
'#l10n 95 (ES - One \$)\n'
"#l10n 96 (ES - Flutter's amazing!)\n"
"#l10n 97 (ES - Flutter's amazing, times 2!)\n"
'#l10n 98 (ES - Flutter is "amazing"!)\n'
'#l10n 99 (ES - Flutter is "amazing", times 2!)\n'
'#l10n 100 (ES - 16 wheel truck)\n'
"#l10n 101 (ES - Sedan's elegance)\n"
'#l10n 102 (ES - Cabriolet has "acceleration")\n'
'#l10n 103 (ES - Oh, she found ES - 1 itemES - !)\n'
'#l10n 104 (ES - Indeed, ES - they like ES - Flutter!)\n'
'#l10n 105 (--- es_419 ---)\n'
'#l10n 106 (ES 419 - Hello World)\n'
'#l10n 107 (ES 419 - Hello)\n'
'#l10n 108 (ES 419 - Hello World)\n'
'#l10n 109 (ES 419 - Hello two worlds)\n'
'#l10n END\n'
);
}

View File

@@ -225,6 +225,11 @@ class Home extends StatelessWidget {
'${localizations.singleQuotePlural(2)}',
'${localizations.doubleQuote}',
'${localizations.doubleQuotePlural(2)}',
"${localizations.vehicleSelect('truck')}",
"${localizations.singleQuoteSelect('sedan')}",
"${localizations.doubleQuoteSelect('cabriolet')}",
"${localizations.pluralInString(1)}",
"${localizations.selectInString('he')}",
]);
},
),
@@ -266,6 +271,11 @@ class Home extends StatelessWidget {
'${localizations.singleQuotePlural(2)}',
'${localizations.doubleQuote}',
'${localizations.doubleQuotePlural(2)}',
"${localizations.vehicleSelect('truck')}",
"${localizations.singleQuoteSelect('sedan')}",
"${localizations.doubleQuoteSelect('cabriolet')}",
"${localizations.pluralInString(1)}",
"${localizations.selectInString('he')}",
]);
},
),
@@ -608,6 +618,46 @@ void main() {
"placeholders": {
"count": {}
}
},
"vehicleSelect": "{vehicleType, select, sedan{Sedan} cabriolet{Solid roof cabriolet} truck{16 wheel truck} other{Other}}",
"@vehicleSelect": {
"description": "A select message.",
"placeholders": {
"vehicleType": {}
}
},
"singleQuoteSelect": "{vehicleType, select, sedan{Sedan's elegance} cabriolet{Cabriolet' acceleration} truck{truck's heavy duty} other{Other's mirrors!}}",
"@singleQuoteSelect": {
"description": "A select message with a single quote.",
"placeholders": {
"vehicleType": {}
}
},
"doubleQuoteSelect": "{vehicleType, select, sedan{Sedan has \"elegance\"} cabriolet{Cabriolet has \"acceleration\"} truck{truck is \"heavy duty\"} other{Other have \"mirrors\"!}}",
"@doubleQuoteSelect": {
"description": "A select message with double quote.",
"placeholders": {
"vehicleType": {}
}
},
"pluralInString": "Oh, she found {count, plural, =1 {1 item} other {all {count} items} }!",
"@pluralInString": {
"description": "A plural message with prefix and suffix strings.",
"placeholders": {
"count": {}
}
},
"selectInString": "Indeed, {gender, select, male {he likes} female {she likes} other {they like} } Flutter!",
"@selectInString": {
"description": "A select message with prefix and suffix strings.",
"placeholders": {
"gender": {}
}
}
}
''';
@@ -646,13 +696,18 @@ void main() {
"helloWorldsOn": "{count,plural, =0{ES - Hello on {date}} =1{ES - Hello World, on {date}} =2{ES - Hello two worlds, on {date}} other{ES - Hello other {count} worlds, on {date}}}",
"helloWorldPopulation": "{ES - count,plural, =1{ES - Hello World of {population} citizens} =2{ES - Hello two worlds with {population} total citizens} many{ES - Hello all {count} worlds, with a total of {population} citizens} other{ES - Hello other {count} worlds, with a total of {population} citizens}}",
"helloWorldInterpolation": "ES - [{hello}] #{world}#",
"helloWorldsInterpolation": "ES - {count,plural, other {ES - [{hello}] -{world}- #{count}#}}",
"helloWorldsInterpolation": "{count,plural, other {ES - [{hello}] -{world}- #{count}#}}",
"dollarSign": "ES - $!",
"dollarSignPlural": "{count,plural, =1{ES - One $} other{ES - Many $}}",
"singleQuote": "ES - Flutter's amazing!",
"singleQuotePlural": "{count,plural, =1{ES - Flutter's amazing, times 1!} other{ES - Flutter's amazing, times {count}!}}",
"doubleQuote": "ES - Flutter is \"amazing\"!",
"doubleQuotePlural": "{count,plural, =1{ES - Flutter is \"amazing\", times 1!} other{ES - Flutter is \"amazing\", times {count}!}}"
"doubleQuotePlural": "{count,plural, =1{ES - Flutter is \"amazing\", times 1!} other{ES - Flutter is \"amazing\", times {count}!}}",
"vehicleSelect": "{vehicleType, select, sedan{ES - Sedan} cabriolet{ES - Solid roof cabriolet} truck{ES - 16 wheel truck} other{ES - Other}}",
"singleQuoteSelect": "{vehicleType, select, sedan{ES - Sedan's elegance} cabriolet{ES - Cabriolet' acceleration} truck{ES - truck's heavy duty} other{ES - Other's mirrors!}}",
"doubleQuoteSelect": "{vehicleType, select, sedan{ES - Sedan has \"elegance\"} cabriolet{ES - Cabriolet has \"acceleration\"} truck{ES - truck is \"heavy duty\"} other{ES - Other have \"mirrors\"!}}",
"pluralInString": "ES - Oh, she found {count, plural, =1 {ES - 1 item} other {ES - all {count} items} }ES - !",
"selectInString": "ES - Indeed, {gender, select, male {ES - he likes} female {ES - she likes} other {ES - they like} } ES - Flutter!"
}
''';