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
38843814
Unverified
Commit
38843814
authored
Jan 31, 2023
by
Tae Hyung Kim
Committed by
GitHub
Jan 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make gen-l10n error handling independent of logger state (#119644)
* init * lint * lint again
parent
8f90e2a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
133 deletions
+160
-133
gen_l10n.dart
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
+138
-133
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+22
-0
No files found.
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
View file @
38843814
...
...
@@ -579,6 +579,10 @@ class LocalizationsGenerator {
// Whether we want to use escaping for ICU messages.
bool
useEscaping
=
false
;
/// Whether any errors were caught. This is set after encountering any errors
/// from calling [_generateMethod].
bool
hadErrors
=
false
;
/// The list of all arb path strings in [inputDirectory].
List
<
String
>
get
arbPathStrings
{
return
_allBundles
.
bundles
.
map
((
AppResourceBundle
bundle
)
=>
bundle
.
file
.
path
).
toList
();
...
...
@@ -1238,6 +1242,7 @@ The plural cases must be one of "=0", "=1", "=2", "zero", "one", "two", "few", "
.
replaceAll
(
'@(none)
\n
'
,
''
);
}
on
L10nParserException
catch
(
error
)
{
logger
.
printError
(
error
.
toString
());
hadErrors
=
true
;
return
''
;
}
}
...
...
@@ -1247,7 +1252,7 @@ The plural cases must be one of "=0", "=1", "=2", "zero", "one", "two", "few", "
final
String
generatedLocalizationsFile
=
_generateCode
();
// If there were any syntax errors, don't write to files.
if
(
logger
.
hadErrorOutput
)
{
if
(
hadErrors
)
{
throw
L10nException
(
'Found syntax errors.'
);
}
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
38843814
...
...
@@ -785,6 +785,28 @@ void main() {
});
group
(
'generateLocalizations'
,
()
{
// Regression test for https://github.com/flutter/flutter/issues/119593
testWithoutContext
(
'other logs from flutter_tools does not affect gen-l10n'
,
()
async
{
_standardFlutterDirectoryL10nSetup
(
fs
);
final
Logger
logger
=
BufferLogger
.
test
();
logger
.
printError
(
'An error output from a different tool in flutter_tools'
);
// Should run without error.
generateLocalizations
(
fileSystem:
fs
,
options:
LocalizationOptions
(
arbDirectory:
Uri
.
directory
(
defaultL10nPathString
),
outputDirectory:
Uri
.
directory
(
defaultL10nPathString
,
windows:
false
),
templateArbFile:
Uri
.
file
(
defaultTemplateArbFileName
,
windows:
false
),
useSyntheticPackage:
false
,
),
logger:
logger
,
projectDir:
fs
.
currentDirectory
,
dependenciesDir:
fs
.
currentDirectory
,
);
});
testWithoutContext
(
'forwards arguments correctly'
,
()
async
{
_standardFlutterDirectoryL10nSetup
(
fs
);
final
LocalizationOptions
options
=
LocalizationOptions
(
...
...
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