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
583a8122
Unverified
Commit
583a8122
authored
Jan 10, 2023
by
Tae Hyung Kim
Committed by
GitHub
Jan 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow select cases to be numbers (#116625)
parent
ad7322dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
message_parser.dart
...s/flutter_tools/lib/src/localizations/message_parser.dart
+9
-1
message_parser_test.dart
...flutter_tools/test/general.shard/message_parser_test.dart
+11
-0
No files found.
packages/flutter_tools/lib/src/localizations/message_parser.dart
View file @
583a8122
...
...
@@ -70,6 +70,7 @@ Map<ST, List<List<ST>>> grammar = <ST, List<List<ST>>>{
],
ST
.
selectPart
:
<
List
<
ST
>>[
<
ST
>[
ST
.
identifier
,
ST
.
openBrace
,
ST
.
message
,
ST
.
closeBrace
],
<
ST
>[
ST
.
number
,
ST
.
openBrace
,
ST
.
message
,
ST
.
closeBrace
],
<
ST
>[
ST
.
other
,
ST
.
openBrace
,
ST
.
message
,
ST
.
closeBrace
],
],
};
...
...
@@ -408,6 +409,7 @@ class Parser {
case
ST
.
selectParts
:
if
(
tokens
.
isNotEmpty
&&
(
tokens
[
0
].
type
==
ST
.
identifier
||
tokens
[
0
].
type
==
ST
.
number
||
tokens
[
0
].
type
==
ST
.
other
))
{
parseAndConstructNode
(
ST
.
selectParts
,
0
);
...
...
@@ -418,8 +420,10 @@ class Parser {
case
ST
.
selectPart
:
if
(
tokens
.
isNotEmpty
&&
tokens
[
0
].
type
==
ST
.
identifier
)
{
parseAndConstructNode
(
ST
.
selectPart
,
0
);
}
else
if
(
tokens
.
isNotEmpty
&&
tokens
[
0
].
type
==
ST
.
oth
er
)
{
}
else
if
(
tokens
.
isNotEmpty
&&
tokens
[
0
].
type
==
ST
.
numb
er
)
{
parseAndConstructNode
(
ST
.
selectPart
,
1
);
}
else
if
(
tokens
.
isNotEmpty
&&
tokens
[
0
].
type
==
ST
.
other
)
{
parseAndConstructNode
(
ST
.
selectPart
,
2
);
}
else
{
throw
L10nParserException
(
'ICU Syntax Error: Select parts must be of the form "identifier { message }"'
,
...
...
@@ -581,6 +585,10 @@ class Parser {
checkExtraRules
(
syntaxTree
);
return
syntaxTree
;
}
on
L10nParserException
catch
(
error
)
{
// For debugging purposes.
if
(
logger
==
null
)
{
rethrow
;
}
logger
?.
printError
(
error
.
toString
());
return
Node
(
ST
.
empty
,
0
,
value:
''
);
}
...
...
packages/flutter_tools/test/general.shard/message_parser_test.dart
View file @
583a8122
...
...
@@ -503,4 +503,15 @@ void main() {
contains(expectedError3),
)));
});
testWithoutContext('
parser
allows
select
cases
with
numbers
', () {
final Node node = Parser('
numberSelect
', '
app_en
.
arb
', '
{
count
,
select
,
0
{
none
}
100
{
perfect
}
other
{
required
!}
}
').parse();
final Node selectExpr = node.children[0];
final Node selectParts = selectExpr.children[5];
final Node selectPart = selectParts.children[0];
expect(selectPart.children[0].value, equals('
0
'));
expect(selectPart.children[1].value, equals('
{
'));
expect(selectPart.children[2].type, equals(ST.message));
expect(selectPart.children[3].value, equals('
}
'));
});
}
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