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
bf132dae
Unverified
Commit
bf132dae
authored
Jul 22, 2021
by
Ahmed Ashour
Committed by
GitHub
Jul 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gen_l10n] correct variable name when the placeholder requiresFormatting (#86842)
parent
def18c71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
+30
-28
gen_l10n.dart
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
+17
-27
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+13
-1
No files found.
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
View file @
bf132dae
...
...
@@ -202,21 +202,16 @@ String _generatePluralMethod(Message message, String translationForMessage) {
if
(
match
!=
null
&&
match
.
groupCount
==
2
)
{
String
argValue
=
generateString
(
match
.
group
(
2
)!);
for
(
final
Placeholder
placeholder
in
message
.
placeholders
)
{
if
(
placeholder
!=
countPlaceholder
&&
placeholder
.
requiresFormatting
)
{
argValue
=
argValue
.
replaceAll
(
'#
${placeholder.name}
#'
,
_needsCurlyBracketStringInterpolation
(
argValue
,
placeholder
.
name
)
?
'
\
${${placeholder.name}
String}'
:
'
\$
${placeholder.name}
String'
);
}
else
{
argValue
=
argValue
.
replaceAll
(
'#
${placeholder.name}
#'
,
_needsCurlyBracketStringInterpolation
(
argValue
,
placeholder
.
name
)
?
'
\
${${placeholder.name}
}'
:
'
\$
${placeholder.name}
'
);
String
variable
=
placeholder
.
name
;
if
(
placeholder
.
requiresFormatting
)
{
variable
+=
'String'
;
}
argValue
=
argValue
.
replaceAll
(
'#
${placeholder.name}
#'
,
_needsCurlyBracketStringInterpolation
(
argValue
,
placeholder
.
name
)
?
'
\
${$variable}
'
:
'
\$
$variable
'
);
}
pluralLogicArgs
.
add
(
'
${pluralIds[pluralKey]}
:
$argValue
'
);
}
...
...
@@ -368,21 +363,16 @@ String _generateMethod(Message message, String translationForMessage) {
String
generateMessage
()
{
String
messageValue
=
generateString
(
translationForMessage
);
for
(
final
Placeholder
placeholder
in
message
.
placeholders
)
{
String
variable
=
placeholder
.
name
;
if
(
placeholder
.
requiresFormatting
)
{
messageValue
=
messageValue
.
replaceAll
(
'{
${placeholder.name}
}'
,
_needsCurlyBracketStringInterpolation
(
messageValue
,
placeholder
.
name
)
?
'
\
${${placeholder.name}
String}'
:
'
\$
${placeholder.name}
String'
);
}
else
{
messageValue
=
messageValue
.
replaceAll
(
'{
${placeholder.name}
}'
,
_needsCurlyBracketStringInterpolation
(
messageValue
,
placeholder
.
name
)
?
'
\
${${placeholder.name}
}'
:
'
\$
${placeholder.name}
'
);
variable
+=
'String'
;
}
messageValue
=
messageValue
.
replaceAll
(
'{
${placeholder.name}
}'
,
_needsCurlyBracketStringInterpolation
(
messageValue
,
placeholder
.
name
)
?
'
\
${$variable}
'
:
'
\$
$variable
'
);
}
return
messageValue
;
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
bf132dae
...
...
@@ -2166,6 +2166,16 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
"placeholders": {
"count": {}
}
},
"third": "{total,plural, =0{test {total}} other{ {total}}",
"@third": {
"description": "Third set of plural messages to test, for number.",
"placeholders": {
"total": {
"type": "int",
"format": "compactLong"
}
}
}
}
'''
;
...
...
@@ -2206,6 +2216,9 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
expect
(
localizationsFile
,
contains
(
r'${count}m'
));
expect
(
localizationsFile
,
contains
(
r'test $count'
));
expect
(
localizationsFile
,
contains
(
r' $count'
));
expect
(
localizationsFile
,
contains
(
r'String totalString = totalNumberFormat'
));
expect
(
localizationsFile
,
contains
(
r'test $totalString'
));
expect
(
localizationsFile
,
contains
(
r' $totalString'
));
});
testWithoutContext
(
...
...
@@ -2493,7 +2506,6 @@ String orderNumber(int number) {
final
String
localizationsFile
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file.dart'
),
).
readAsStringSync
();
print
(
localizationsFile
);
expect
(
localizationsFile
,
containsIgnoringWhitespace
(
r''
'
AppLocalizations lookupAppLocalizations(Locale locale) {
'''
));
...
...
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