Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9b3754d5
Unverified
Commit
9b3754d5
authored
Feb 25, 2020
by
Hans Muller
Committed by
GitHub
Feb 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend the gen_l10n integration test (#51375)
parent
eb00c562
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
58 deletions
+118
-58
gen_l10n_test.dart
...s/flutter_tools/test/integration.shard/gen_l10n_test.dart
+26
-23
gen_l10n_project.dart
...ls/test/integration.shard/test_data/gen_l10n_project.dart
+92
-35
No files found.
packages/flutter_tools/test/integration.shard/gen_l10n_test.dart
View file @
9b3754d5
...
...
@@ -76,29 +76,32 @@ void main() {
await
l10nEnd
.
future
;
await
subscription
.
cancel
();
expect
(
stdout
.
toString
(),
'#l10n 0 (Hello World)
\n
'
'#l10n 1 (Hello World)
\n
'
'#l10n 2 (Hello World)
\n
'
'#l10n 3 (Hello World on Friday, January 1, 1960)
\n
'
'#l10n 4 (Hello world argument on 1/1/1960 at 00:00)
\n
'
'#l10n 5 (Hello World from 1960 to 2020)
\n
'
'#l10n 6 (Hello for 123)
\n
'
'#l10n 7 (Hello for price USD123.00)
\n
'
'#l10n 8 (Hello)
\n
'
'#l10n 9 (Hello World)
\n
'
'#l10n 10 (Hello two worlds)
\n
'
'#l10n 11 (Hello on Friday, January 1, 1960)
\n
'
'#l10n 12 (Hello World, on Friday, January 1, 1960)
\n
'
'#l10n 13 (Hello two worlds, on Friday, January 1, 1960)
\n
'
'#l10n 14 (Hello)
\n
'
'#l10n 15 (Hello new World)
\n
'
'#l10n 16 (Hello two new worlds)
\n
'
'#l10n 17 (Hello other 0 worlds, with a total of 100 citizens)
\n
'
'#l10n 18 (Hello World of 101 citizens)
\n
'
'#l10n 19 (Hello two worlds with 102 total citizens)
\n
'
'#l10n 20 ([Hello] #World#)
\n
'
'#l10n 21 ([Hello] -World- #123#)
\n
'
'#l10n END
\n
'
'#l10n 0 (CA Hello World)
\n
'
'#l10n 1 (Hello CA fallback World)
\n
'
'#l10n 2 (GB Hello World)
\n
'
'#l10n 3 (Hello GB fallback World)
\n
'
'#l10n 4 (Hello World)
\n
'
'#l10n 5 (Hello World)
\n
'
'#l10n 6 (Hello World)
\n
'
'#l10n 7 (Hello World on Friday, January 1, 1960)
\n
'
'#l10n 8 (Hello world argument on 1/1/1960 at 00:00)
\n
'
'#l10n 9 (Hello World from 1960 to 2020)
\n
'
'#l10n 10 (Hello for 123)
\n
'
'#l10n 11 (Hello for price USD123.00)
\n
'
'#l10n 12 (Hello)
\n
'
'#l10n 13 (Hello World)
\n
'
'#l10n 14 (Hello two worlds)
\n
'
'#l10n 15 (Hello)
\n
'
'#l10n 16 (Hello new World)
\n
'
'#l10n 17 (Hello two new worlds)
\n
'
'#l10n 18 (Hello on Friday, January 1, 1960)
\n
'
'#l10n 19 (Hello World, on Friday, January 1, 1960)
\n
'
'#l10n 20 (Hello two worlds, on Friday, January 1, 1960)
\n
'
'#l10n 21 (Hello other 0 worlds, with a total of 100 citizens)
\n
'
'#l10n 22 (Hello World of 101 citizens)
\n
'
'#l10n 23 (Hello two worlds with 102 total citizens)
\n
'
'#l10n 24 ([Hello] -World- #123#)
\n
'
'#l10n END
\n
'
);
});
}
packages/flutter_tools/test/integration.shard/test_data/gen_l10n_project.dart
View file @
9b3754d5
...
...
@@ -16,6 +16,8 @@ class GenL10nProject extends Project {
Future
<
void
>
setUpIn
(
Directory
dir
)
{
this
.
dir
=
dir
;
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
);
return
super
.
setUpIn
(
dir
);
}
...
...
@@ -40,44 +42,85 @@ import 'package:flutter/material.dart';
import '
l10n
/
app_localizations
.
dart
';
class LocaleBuilder extends StatelessWidget {
const LocaleBuilder({ Key key, this.locale, this.callback }) : super(key: key);
final Locale locale;
final void Function (BuildContext context) callback;
@override build(BuildContext context) {
return Localizations.override(
locale: locale,
context: context,
child: Builder(
builder: (BuildContext context) {
callback(context);
return Container();
},
),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
try {
final AppLocalizations localizations = AppLocalizations.of(context);
final List<String> results = <String>[
'
$
{
localizations
.
helloWorld
}
',
'
$
{
localizations
.
hello
(
"World"
)}
',
'
$
{
localizations
.
greeting
(
"Hello"
,
"World"
)}
',
'
$
{
localizations
.
helloWorldOn
(
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloOn
(
"world argument"
,
DateTime
(
1960
),
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloWorldDuring
(
DateTime
(
1960
),
DateTime
(
2020
))}
',
'
$
{
localizations
.
helloFor
(
123
)}
',
'
$
{
localizations
.
helloCost
(
"price"
,
123
)}
',
'
$
{
localizations
.
helloWorlds
(
0
)}
',
'
$
{
localizations
.
helloWorlds
(
1
)}
',
'
$
{
localizations
.
helloWorlds
(
2
)}
',
'
$
{
localizations
.
helloWorldsOn
(
0
,
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloWorldsOn
(
1
,
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloWorldsOn
(
2
,
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
0
,
"new"
)}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
1
,
"new"
)}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
2
,
"new"
)}
',
'
$
{
localizations
.
helloWorldPopulation
(
0
,
100
)}
',
'
$
{
localizations
.
helloWorldPopulation
(
1
,
101
)}
',
'
$
{
localizations
.
helloWorldPopulation
(
2
,
102
)}
',
'
$
{
localizations
.
helloWorldInterpolation
(
"Hello"
,
"World"
)}
',
'
$
{
localizations
.
helloWorldsInterpolation
(
123
,
"Hello"
,
"World"
)}
',
];
int n = 0;
for (final String result in results) {
print('
#l10n
$n
(
$result
)
\
n
');
n += 1;
}
} finally {
print('
#l10n
END
\
n
');
}
return Container();
final List<String> results = [];
return Row(
children: <Widget>[
LocaleBuilder(
locale: Locale('
en
', '
CA
'),
callback: (BuildContext context) {
results.add(AppLocalizations.of(context).helloWorld);
results.add(AppLocalizations.of(context).hello("CA fallback World"));
},
),
LocaleBuilder(
locale: Locale('
en
', '
GB
'),
callback: (BuildContext context) {
results.add(AppLocalizations.of(context).helloWorld);
results.add(AppLocalizations.of(context).hello("GB fallback World"));
},
),
LocaleBuilder(
locale: Locale('
en
'),
callback: (BuildContext context) {
int n = 0;
try {
final AppLocalizations localizations = AppLocalizations.of(context);
results.addAll(<String>[
'
$
{
localizations
.
helloWorld
}
',
'
$
{
localizations
.
hello
(
"World"
)}
',
'
$
{
localizations
.
greeting
(
"Hello"
,
"World"
)}
',
'
$
{
localizations
.
helloWorldOn
(
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloOn
(
"world argument"
,
DateTime
(
1960
),
DateTime
(
1960
))}
',
'
$
{
localizations
.
helloWorldDuring
(
DateTime
(
1960
),
DateTime
(
2020
))}
',
'
$
{
localizations
.
helloFor
(
123
)}
',
'
$
{
localizations
.
helloCost
(
"price"
,
123
)}
',
'
$
{
localizations
.
helloWorlds
(
0
)}
',
'
$
{
localizations
.
helloWorlds
(
1
)}
',
'
$
{
localizations
.
helloWorlds
(
2
)}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
0
,
"new"
)}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
1
,
"new"
)}
',
'
$
{
localizations
.
helloAdjectiveWorlds
(
2
,
"new"
)}
',
'
$
{
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
,
"Hello"
,
"World"
)}
',
]);
for (final String result in results) {
print('
#l10n
$n
(
$result
)
\
n
');
n += 1;
}
}
finally {
print('
#l10n
END
\
n
');
}
},
),
],
);
}
}
...
...
@@ -245,5 +288,19 @@ void main() {
}
}
}
'''
;
final
String
appEnCa
=
r''
'
{
"@@locale": "en_CA",
"helloWorld": "CA Hello World"
}
'''
;
final
String
appEnGb
=
r''
'
{
"@@locale": "en_GB",
"helloWorld": "GB Hello World"
}
'''
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment