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
ee17ebe5
Unverified
Commit
ee17ebe5
authored
May 24, 2021
by
Michael Goderbauer
Committed by
GitHub
May 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use type:int without format in gen_l10n (#83132)
parent
c52e8495
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
gen_l10n_types.dart
...s/flutter_tools/lib/src/localizations/gen_l10n_types.dart
+1
-1
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+41
-0
No files found.
packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart
View file @
ee17ebe5
...
...
@@ -202,7 +202,7 @@ class Placeholder {
final
String
?
format
;
final
List
<
OptionalParameter
>
optionalParameters
;
bool
get
requiresFormatting
=>
<
String
>[
'DateTime'
,
'double'
,
'
int'
,
'num'
].
contains
(
type
);
bool
get
requiresFormatting
=>
<
String
>[
'DateTime'
,
'double'
,
'
num'
].
contains
(
type
)
||
(
type
==
'int'
&&
format
!=
null
);
bool
get
isNumber
=>
<
String
>[
'double'
,
'int'
,
'num'
].
contains
(
type
);
bool
get
hasValidNumberFormat
=>
_validNumberFormats
.
contains
(
format
);
bool
get
hasNumberFormatWithParameters
=>
_numberFormatsWithNamedParameters
.
contains
(
format
);
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
ee17ebe5
...
...
@@ -2399,4 +2399,45 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
// The original pubspec file should not be overwritten.
expect
(
pubspecFile
.
readAsStringSync
(),
'abcd'
);
});
testWithoutContext
(
'can use type: int without specifying a format'
,
()
{
const
String
arbFile
=
'''
{
"orderNumber": "This is order #{number}.",
"@orderNumber": {
"description": "The title for an order with a given number.",
"placeholders": {
"number": {
"type": "int"
}
}
}
}'''
;
final
Directory
l10nDirectory
=
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
);
l10nDirectory
.
childFile
(
defaultTemplateArbFileName
)
.
writeAsStringSync
(
arbFile
);
LocalizationsGenerator
(
fileSystem:
fs
,
inputPathString:
defaultL10nPathString
,
outputPathString:
defaultL10nPathString
,
templateArbFileName:
defaultTemplateArbFileName
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
)
..
loadResources
()
..
writeOutputFiles
(
BufferLogger
.
test
());
final
String
localizationsFile
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file_en.dart'
),
).
readAsStringSync
();
expect
(
localizationsFile
,
containsIgnoringWhitespace
(
r''
'
String orderNumber(int number) {
return '
This
is
order
#
$number
.
';
}
'''
));
expect
(
localizationsFile
,
isNot
(
contains
(
intlImportDartCode
)));
});
}
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