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
4d663472
Unverified
Commit
4d663472
authored
Jan 04, 2021
by
Shi-Hao Hong
Committed by
GitHub
Jan 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gen_l10n] Improve status message when untranslated messages are still present (#72944)
parent
14cbd6d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
8 deletions
+69
-8
localizations.dart
...ter_tools/lib/src/build_system/targets/localizations.dart
+1
-1
gen_l10n.dart
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
+19
-4
localizations_test.dart
...eneral.shard/build_system/targets/localizations_test.dart
+1
-1
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+48
-2
No files found.
packages/flutter_tools/lib/src/build_system/targets/localizations.dart
View file @
4d663472
...
...
@@ -66,7 +66,7 @@ void generateLocalizations({
untranslatedMessagesFile:
options
?.
untranslatedMessagesFile
?.
toFilePath
(),
)
..
loadResources
()
..
writeOutputFiles
(
logger
);
..
writeOutputFiles
(
logger
,
isFromYaml:
true
);
}
on
L10nException
catch
(
e
)
{
logger
.
printError
(
e
.
message
);
throw
Exception
();
...
...
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
View file @
4d663472
...
...
@@ -1033,7 +1033,7 @@ class LocalizationsGenerator {
.
replaceAll
(
'@(delegateClass)'
,
delegateClass
);
}
void
writeOutputFiles
(
Logger
logger
)
{
void
writeOutputFiles
(
Logger
logger
,
{
bool
isFromYaml
=
false
}
)
{
// First, generate the string contents of all necessary files.
_generateCode
();
...
...
@@ -1077,10 +1077,25 @@ class LocalizationsGenerator {
_unimplementedMessages
.
forEach
((
LocaleInfo
locale
,
List
<
String
>
messages
)
{
logger
.
printStatus
(
'"
$locale
":
${messages.length}
untranslated message(s).'
);
});
if
(
isFromYaml
)
{
logger
.
printStatus
(
'To see a detailed report, use the untranslated-messages-file
\n
'
'option in the l10n.yaml file:
\n
'
'untranslated-messages-file: desiredFileName.txt
\n
'
'<other option>: <other selection>
\n\n
'
);
}
else
{
logger
.
printStatus
(
'To see a detailed report, use the --untranslated-messages-file
\n
'
'option in the flutter gen-l10n tool:
\n
'
'flutter gen-l10n --untranslated-messages-file=desiredFileName.txt
\n
'
'<other options>
\n\n
'
);
}
logger
.
printStatus
(
'To see a detailed report, use the --untranslated-messages-file
\n
'
'option in the tool to generate a JSON format file containing
\n
'
'all messages that need to be translated.'
'This will generate a JSON format file containing all messages that
\n
'
'need to be translated.'
);
}
...
...
packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
View file @
4d663472
...
...
@@ -70,7 +70,7 @@ void main() {
),
).
called
(
1
);
verify
(
mockLocalizationsGenerator
.
loadResources
()).
called
(
1
);
verify
(
mockLocalizationsGenerator
.
writeOutputFiles
(
logger
)).
called
(
1
);
verify
(
mockLocalizationsGenerator
.
writeOutputFiles
(
logger
,
isFromYaml:
true
)).
called
(
1
);
});
testUsingContext
(
'generateLocalizations throws exception on missing flutter: generate: true flag'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
4d663472
...
...
@@ -548,7 +548,8 @@ void main() {
});
test
(
'untranslated messages suggestion is printed when translation is missing'
,
'untranslated messages suggestion is printed when translation is missing: '
'command line message'
,
()
{
final
BufferLogger
testLogger
=
BufferLogger
.
test
();
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
...
...
@@ -566,6 +567,7 @@ void main() {
templateArbFileName:
defaultTemplateArbFileName
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
useSyntheticPackage:
false
,
)
..
loadResources
()
..
writeOutputFiles
(
testLogger
);
...
...
@@ -573,7 +575,51 @@ void main() {
fail
(
'Generating output should not fail:
\n
${e.message}
'
);
}
expect
(
testLogger
.
statusText
,
contains
(
'To see a detailed report, use the --untranslated-messages-file'
));
expect
(
testLogger
.
statusText
,
contains
(
'To see a detailed report, use the --untranslated-messages-file'
),
);
expect
(
testLogger
.
statusText
,
contains
(
'flutter gen-l10n --untranslated-messages-file=desiredFileName.txt'
),
);
},
);
test
(
'untranslated messages suggestion is printed when translation is missing: '
'l10n.yaml message'
,
()
{
final
BufferLogger
testLogger
=
BufferLogger
.
test
();
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
)
..
childFile
(
defaultTemplateArbFileName
).
writeAsStringSync
(
twoMessageArbFileString
)
..
childFile
(
esArbFileName
).
writeAsStringSync
(
singleEsMessageArbFileString
);
LocalizationsGenerator
generator
;
try
{
generator
=
LocalizationsGenerator
(
fs
);
generator
..
initialize
(
inputPathString:
defaultL10nPathString
,
templateArbFileName:
defaultTemplateArbFileName
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
)
..
loadResources
()
..
writeOutputFiles
(
testLogger
,
isFromYaml:
true
);
}
on
L10nException
catch
(
e
)
{
fail
(
'Generating output should not fail:
\n
${e.message}
'
);
}
expect
(
testLogger
.
statusText
,
contains
(
'To see a detailed report, use the untranslated-messages-file'
),
);
expect
(
testLogger
.
statusText
,
contains
(
'untranslated-messages-file: desiredFileName.txt'
),
);
},
);
...
...
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