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
21f3ce8b
Unverified
Commit
21f3ce8b
authored
Dec 06, 2022
by
Tae Hyung Kim
Committed by
GitHub
Dec 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gen_l10n] Multiline descriptions (#116380)
* init * empty commit to start google testing
parent
e2fb672a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
3 deletions
+77
-3
gen_l10n.dart
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
+5
-1
gen_l10n_templates.dart
...utter_tools/lib/src/localizations/gen_l10n_templates.dart
+2
-2
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+70
-0
No files found.
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
View file @
21f3ce8b
...
@@ -201,7 +201,11 @@ Map<String, String> pluralCases = <String, String>{
...
@@ -201,7 +201,11 @@ Map<String, String> pluralCases = <String, String>{
};
};
String
generateBaseClassMethod
(
Message
message
,
LocaleInfo
?
templateArbLocale
)
{
String
generateBaseClassMethod
(
Message
message
,
LocaleInfo
?
templateArbLocale
)
{
final
String
comment
=
message
.
description
??
'No description provided for @
${message.resourceId}
.'
;
final
String
comment
=
message
.
description
?.
split
(
'
\n
'
)
.
map
((
String
line
)
=>
' ///
$line
'
)
.
join
(
'
\n
'
)
??
' /// No description provided for @
${message.resourceId}
.'
;
final
String
templateLocaleTranslationComment
=
'''
final
String
templateLocaleTranslationComment
=
'''
/// In
$templateArbLocale
, this message translates to:
/// In
$templateArbLocale
, this message translates to:
/// **'
$
{
generateString
(
message
.
value
)}
'**'''
;
/// **'
$
{
generateString
(
message
.
value
)}
'**'''
;
...
...
packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart
View file @
21f3ce8b
...
@@ -179,14 +179,14 @@ class @(class) extends @(baseLanguageClassName) {
...
@@ -179,14 +179,14 @@ class @(class) extends @(baseLanguageClassName) {
''';
''';
const String baseClassGetterTemplate = '''
const String baseClassGetterTemplate = '''
///
@(comment)
@
(
comment
)
///
///
@
(
templateLocaleTranslationComment
)
@
(
templateLocaleTranslationComment
)
String
get
@
(
name
);
String
get
@
(
name
);
''';
''';
const String baseClassMethodTemplate = '''
const String baseClassMethodTemplate = '''
///
@(comment)
@
(
comment
)
///
///
@
(
templateLocaleTranslationComment
)
@
(
templateLocaleTranslationComment
)
String
@
(
name
)(
@
(
parameters
));
String
@
(
name
)(
@
(
parameters
));
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
21f3ce8b
...
@@ -1318,6 +1318,76 @@ class AppLocalizationsEn extends AppLocalizations {
...
@@ -1318,6 +1318,76 @@ class AppLocalizationsEn extends AppLocalizations {
^'''
));
^'''
));
}
}
});
});
testWithoutContext
(
'no description generates generic comment'
,
()
{
final
Directory
l10nDirectory
=
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
);
l10nDirectory
.
childFile
(
defaultTemplateArbFileName
)
.
writeAsStringSync
(
r''
'
{
"helloWorld": "Hello world!"
}'''
);
l10nDirectory
.
childFile
(
esArbFileName
)
.
writeAsStringSync
(
singleEsMessageArbFileString
);
LocalizationsGenerator
(
fileSystem:
fs
,
inputPathString:
defaultL10nPathString
,
outputPathString:
defaultL10nPathString
,
templateArbFileName:
defaultTemplateArbFileName
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
logger:
logger
,
)
..
loadResources
()
..
writeOutputFiles
();
final
File
baseLocalizationsFile
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file.dart'
)
);
expect
(
baseLocalizationsFile
.
existsSync
(),
isTrue
);
final
String
baseLocalizationsFileContents
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file.dart'
)
).
readAsStringSync
();
expect
(
baseLocalizationsFileContents
,
contains
(
'/// No description provided for @helloWorld.'
));
});
testWithoutContext
(
'multiline descriptions are correctly formatted as comments'
,
()
{
final
Directory
l10nDirectory
=
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
);
l10nDirectory
.
childFile
(
defaultTemplateArbFileName
)
.
writeAsStringSync
(
r''
'
{
"helloWorld": "Hello world!",
"@helloWorld": {
"description": "The generic example string in every language.
\n
Use this for tests!"
}
}'''
);
l10nDirectory
.
childFile
(
esArbFileName
)
.
writeAsStringSync
(
singleEsMessageArbFileString
);
LocalizationsGenerator
(
fileSystem:
fs
,
inputPathString:
defaultL10nPathString
,
outputPathString:
defaultL10nPathString
,
templateArbFileName:
defaultTemplateArbFileName
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
logger:
logger
,
)
..
loadResources
()
..
writeOutputFiles
();
final
File
baseLocalizationsFile
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file.dart'
)
);
expect
(
baseLocalizationsFile
.
existsSync
(),
isTrue
);
final
String
baseLocalizationsFileContents
=
fs
.
file
(
fs
.
path
.
join
(
syntheticL10nPackagePath
,
'output-localization-file.dart'
)
).
readAsStringSync
();
expect
(
baseLocalizationsFileContents
,
contains
(
'''
/// The generic example string in every language.
/// Use this for tests!'''
));
});
testWithoutContext
(
'message without placeholders - should generate code comment with description and template message translation'
,
()
{
testWithoutContext
(
'message without placeholders - should generate code comment with description and template message translation'
,
()
{
_standardFlutterDirectoryL10nSetup
(
fs
);
_standardFlutterDirectoryL10nSetup
(
fs
);
LocalizationsGenerator
(
LocalizationsGenerator
(
...
...
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