Unverified Commit c16c3b04 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[gen_l10n] Expand integration tests (#54314)

parent d64955ab
......@@ -86,57 +86,95 @@ void main() {
'#l10n 1 (supportedLocales[0]: languageCode: en, countryCode: null, scriptCode: null)\n'
'#l10n 2 (supportedLocales[1]: languageCode: en, countryCode: CA, scriptCode: null)\n'
'#l10n 3 (supportedLocales[2]: languageCode: en, countryCode: GB, scriptCode: null)\n'
'#l10n 4 (supportedLocales[3]: languageCode: zh, countryCode: null, scriptCode: null)\n'
'#l10n 5 (supportedLocales[4]: languageCode: zh, countryCode: null, scriptCode: Hans)\n'
'#l10n 6 (supportedLocales[5]: languageCode: zh, countryCode: null, scriptCode: Hant)\n'
'#l10n 7 (supportedLocales[6]: languageCode: zh, countryCode: TW, scriptCode: Hant)\n'
'#l10n 8 (--- countryCode (en_CA) tests ---)\n'
'#l10n 9 (CA Hello World)\n'
'#l10n 10 (Hello CA fallback World)\n'
'#l10n 11 (--- countryCode (en_GB) tests ---)\n'
'#l10n 12 (GB Hello World)\n'
'#l10n 13 (Hello GB fallback World)\n'
'#l10n 14 (--- zh ---)\n'
'#l10n 15 (你好世界)\n'
'#l10n 16 (你好)\n'
'#l10n 4 (supportedLocales[3]: languageCode: es, countryCode: null, scriptCode: null)\n'
'#l10n 5 (supportedLocales[4]: languageCode: es, countryCode: 419, scriptCode: null)\n'
'#l10n 6 (supportedLocales[5]: languageCode: zh, countryCode: null, scriptCode: null)\n'
'#l10n 7 (supportedLocales[6]: languageCode: zh, countryCode: null, scriptCode: Hans)\n'
'#l10n 8 (supportedLocales[7]: languageCode: zh, countryCode: null, scriptCode: Hant)\n'
'#l10n 9 (supportedLocales[8]: languageCode: zh, countryCode: TW, scriptCode: Hant)\n'
'#l10n 10 (--- countryCode (en_CA) tests ---)\n'
'#l10n 11 (CA Hello World)\n'
'#l10n 12 (Hello CA fallback World)\n'
'#l10n 13 (--- countryCode (en_GB) tests ---)\n'
'#l10n 14 (GB Hello World)\n'
'#l10n 15 (Hello GB fallback World)\n'
'#l10n 16 (--- zh ---)\n'
'#l10n 17 (你好世界)\n'
'#l10n 18 (你好2个其他世界)\n'
'#l10n 19 (Hello 世界)\n'
'#l10n 20 (--- scriptCode: zh_Hans ---)\n'
'#l10n 21 (简体你好世界)\n'
'#l10n 22 (--- scriptCode - zh_Hant ---)\n'
'#l10n 23 (繁體你好世界)\n'
'#l10n 24 (--- scriptCode - zh_Hant_TW ---)\n'
'#l10n 25 (台灣繁體你好世界)\n'
'#l10n 26 (--- General formatting tests ---)\n'
'#l10n 27 (Hello World)\n'
'#l10n 28 (Hello _NEWLINE_ World)\n'
'#l10n 18 (你好)\n'
'#l10n 19 (你好世界)\n'
'#l10n 20 (你好2个其他世界)\n'
'#l10n 21 (Hello 世界)\n'
'#l10n 22 (--- scriptCode: zh_Hans ---)\n'
'#l10n 23 (简体你好世界)\n'
'#l10n 24 (--- scriptCode - zh_Hant ---)\n'
'#l10n 25 (繁體你好世界)\n'
'#l10n 26 (--- scriptCode - zh_Hant_TW ---)\n'
'#l10n 27 (台灣繁體你好世界)\n'
'#l10n 28 (--- General formatting tests ---)\n'
'#l10n 29 (Hello World)\n'
'#l10n 30 (Hello World)\n'
'#l10n 31 (Hello World on Friday, January 1, 1960)\n'
'#l10n 32 (Hello world argument on 1/1/1960 at 00:00)\n'
'#l10n 33 (Hello World from 1960 to 2020)\n'
'#l10n 34 (Hello for 123)\n'
'#l10n 35 (Hello for price USD123.00)\n'
'#l10n 36 (Hello)\n'
'#l10n 37 (Hello World)\n'
'#l10n 38 (Hello two worlds)\n'
'#l10n 39 (Hello)\n'
'#l10n 40 (Hello new World)\n'
'#l10n 41 (Hello two new worlds)\n'
'#l10n 42 (Hello on Friday, January 1, 1960)\n'
'#l10n 43 (Hello World, on Friday, January 1, 1960)\n'
'#l10n 44 (Hello two worlds, on Friday, January 1, 1960)\n'
'#l10n 45 (Hello other 0 worlds, with a total of 100 citizens)\n'
'#l10n 46 (Hello World of 101 citizens)\n'
'#l10n 47 (Hello two worlds with 102 total citizens)\n'
'#l10n 48 ([Hello] -World- #123#)\n'
'#l10n 49 (\$!)\n'
'#l10n 50 (One \$)\n'
'#l10n 51 (Flutter\'s amazing!)\n'
'#l10n 52 (Flutter\'s amazing, times 2!)\n'
'#l10n 53 (Flutter is "amazing"!)\n'
'#l10n 54 (Flutter is "amazing", times 2!)\n'
'#l10n 30 (Hello _NEWLINE_ World)\n'
'#l10n 31 (Hello World)\n'
'#l10n 32 (Hello World)\n'
'#l10n 33 (Hello World on Friday, January 1, 1960)\n'
'#l10n 34 (Hello world argument on 1/1/1960 at 00:00)\n'
'#l10n 35 (Hello World from 1960 to 2020)\n'
'#l10n 36 (Hello for 123)\n'
'#l10n 37 (Hello for price USD123.00)\n'
'#l10n 38 (Hello)\n'
'#l10n 39 (Hello World)\n'
'#l10n 40 (Hello two worlds)\n'
'#l10n 41 (Hello)\n'
'#l10n 42 (Hello new World)\n'
'#l10n 43 (Hello two new worlds)\n'
'#l10n 44 (Hello on Friday, January 1, 1960)\n'
'#l10n 45 (Hello World, on Friday, January 1, 1960)\n'
'#l10n 46 (Hello two worlds, on Friday, January 1, 1960)\n'
'#l10n 47 (Hello other 0 worlds, with a total of 100 citizens)\n'
'#l10n 48 (Hello World of 101 citizens)\n'
'#l10n 49 (Hello two worlds with 102 total citizens)\n'
'#l10n 50 ([Hello] -World- #123#)\n'
'#l10n 51 (\$!)\n'
'#l10n 52 (One \$)\n'
'#l10n 53 (Flutter\'s amazing!)\n'
'#l10n 54 (Flutter\'s amazing, times 2!)\n'
'#l10n 55 (Flutter is "amazing"!)\n'
'#l10n 56 (Flutter is "amazing", times 2!)\n'
'#l10n 57 (--- es ---)\n'
'#l10n 58 (ES - Hello world)\n'
'#l10n 59 (ES - Hello _NEWLINE_ World)\n'
'#l10n 60 (ES - Hello Mundo)\n'
'#l10n 61 (ES - Hola Mundo)\n'
'#l10n 62 (ES - Hello World on viernes, 1 de enero de 1960)\n'
'#l10n 63 (ES - Hello world argument on 1/1/1960 at 0:00)\n'
'#l10n 64 (ES - Hello World from 1960 to 2020)\n'
'#l10n 65 (ES - Hello for 123)\n'
// Note that the space between "123.00" and "EUR" is a
// non-breaking space (U+00A0) and not a regular space(U+0020)
'#l10n 66 (ES - Hello for el precio 123,00 EUR)\n'
'#l10n 67 (ES - Hello)\n'
'#l10n 68 (ES - Hello World)\n'
'#l10n 69 (ES - Hello two worlds)\n'
'#l10n 70 (ES - Hello)\n'
'#l10n 71 (ES - Hello nuevo World)\n'
'#l10n 72 (ES - Hello two nuevo worlds)\n'
'#l10n 73 (ES - Hello on viernes, 1 de enero de 1960)\n'
'#l10n 74 (ES - Hello World, on viernes, 1 de enero de 1960)\n'
'#l10n 75 (ES - Hello two worlds, on viernes, 1 de enero de 1960)\n'
'#l10n 76 (ES - Hello other 0 worlds, with a total of 100 citizens)\n'
'#l10n 77 (ES - Hello World of 101 citizens)\n'
'#l10n 78 (ES - Hello two worlds with 102 total citizens)\n'
'#l10n 79 (ES - [Hola] -Mundo- #123#)\n'
'#l10n 80 (ES - \$!)\n'
'#l10n 81 (ES - One \$)\n'
'#l10n 82 (ES - Flutter\'s amazing!)\n'
'#l10n 83 (ES - Flutter\'s amazing, times 2!)\n'
'#l10n 84 (ES - Flutter is "amazing"!)\n'
'#l10n 85 (ES - Flutter is "amazing", times 2!)\n'
'#l10n 86 (--- es_419 ---)\n'
'#l10n 87 (ES 419 - Hello World)\n'
'#l10n 88 (ES 419 - Hello)\n'
'#l10n 89 (ES 419 - Hello World)\n'
'#l10n 90 (ES 419 - Hello two worlds)\n'
'#l10n END\n'
);
}
......
......@@ -18,6 +18,8 @@ class GenL10nProject extends Project {
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en.arb'), appEn);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en_CA.arb'), appEnCa);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en_GB.arb'), appEnGb);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_es.arb'), appEs);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_es_419.arb'), appEs419);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh.arb'), appZh);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hant.arb'), appZhHant);
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hans.arb'), appZhHans);
......@@ -196,6 +198,58 @@ class Home extends StatelessWidget {
]);
},
),
LocaleBuilder(
locale: Locale('es'),
test: '--- es ---',
callback: (BuildContext context) {
results.add('--- es ---');
final AppLocalizations localizations = AppLocalizations.of(context);
results.addAll(<String>[
'${localizations.helloWorld}',
'${localizations.helloNewlineWorld}',
'${localizations.hello("Mundo")}',
'${localizations.greeting("Hola", "Mundo")}',
'${localizations.helloWorldOn(DateTime(1960))}',
'${localizations.helloOn("world argument", DateTime(1960), DateTime(1960))}',
'${localizations.helloWorldDuring(DateTime(1960), DateTime(2020))}',
'${localizations.helloFor(123)}',
'${localizations.helloCost("el precio", 123)}',
'${localizations.helloWorlds(0)}',
'${localizations.helloWorlds(1)}',
'${localizations.helloWorlds(2)}',
'${localizations.helloAdjectiveWorlds(0, "nuevo")}',
'${localizations.helloAdjectiveWorlds(1, "nuevo")}',
'${localizations.helloAdjectiveWorlds(2, "nuevo")}',
'${localizations.helloWorldsOn(0, DateTime(1960))}',
'${localizations.helloWorldsOn(1, DateTime(1960))}',
'${localizations.helloWorldsOn(2, DateTime(1960))}',
'${localizations.helloWorldPopulation(0, 100)}',
'${localizations.helloWorldPopulation(1, 101)}',
'${localizations.helloWorldPopulation(2, 102)}',
'${localizations.helloWorldsInterpolation(123, "Hola", "Mundo")}',
'${localizations.dollarSign}',
'${localizations.dollarSignPlural(1)}',
'${localizations.singleQuote}',
'${localizations.singleQuotePlural(2)}',
'${localizations.doubleQuote}',
'${localizations.doubleQuotePlural(2)}',
]);
},
),
LocaleBuilder(
locale: Locale.fromSubtags(languageCode: 'es', countryCode: '419'),
test: 'countryCode - es_419',
callback: (BuildContext context) {
results.add('--- es_419 ---');
final AppLocalizations localizations = AppLocalizations.of(context);
results.addAll([
'${localizations.helloWorld}',
'${localizations.helloWorlds(0)}',
'${localizations.helloWorlds(1)}',
'${localizations.helloWorlds(2)}',
]);
},
),
Builder(
builder: (BuildContext context) {
try {
......@@ -439,6 +493,44 @@ void main() {
"@@locale": "en_GB",
"helloWorld": "GB Hello World"
}
''';
/// All messages are simply the template language's message with 'ES - '
/// appended. This makes validating test behavior easier. The interpolated
/// messages are different where applicable.
final String appEs = r'''
{
"@@locale": "es",
"helloWorld": "ES - Hello world",
"helloWorlds": "{count,plural, =0{ES - Hello} =1{ES - Hello World} =2{ES - Hello two worlds} few{ES - Hello {count} worlds} many{ES - Hello all {count} worlds} other{ES - Hello other {count} worlds}}",
"helloNewlineWorld": "ES - Hello \n World",
"hello": "ES - Hello {world}",
"greeting": "ES - {hello} {world}",
"helloWorldOn": "ES - Hello World on {date}",
"helloWorldDuring": "ES - Hello World from {startDate} to {endDate}",
"helloOn": "ES - Hello {world} on {date} at {time}",
"helloFor": "ES - Hello for {value}",
"helloCost": "ES - Hello for {price} {value}",
"helloAdjectiveWorlds": "{count,plural, =0{ES - Hello} =1{ES - Hello {adjective} World} =2{ES - Hello two {adjective} worlds} other{ES - Hello other {count} {adjective} worlds}}",
"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}#}}",
"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}!}}"
}
''';
final String appEs419 = r'''
{
"@@locale": "es_419",
"helloWorld": "ES 419 - Hello World",
"helloWorlds": "{count,plural, =0{ES 419 - Hello} =1{ES 419 - Hello World} =2{ES 419 - Hello two worlds} few{ES 419 - Hello {count} worlds} many{ES 419 - Hello all {count} worlds} other{ES - Hello other {count} worlds}}"
}
''';
final String appZh = r'''
......
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