[gen_l10n] Optional Headers (#52125)

* Expose --header and --header-file arguments for gen_l10n
This commit is contained in:
Shi-Hao Hong
2020-03-11 13:55:54 -07:00
committed by GitHub
parent d56266375b
commit 96fd143cd7
6 changed files with 159 additions and 8 deletions

View File

@@ -56,6 +56,23 @@ Future<void> main(List<String> arguments) async {
"For example, pass in ['en_US'] if you would like your app to "
'default to American English if a device supports it.',
);
parser.addOption(
'header',
help: 'The header to prepend to the generated Dart localizations '
'files. This option takes in a string. \n\n'
'For example, pass in "/// All localized files." if you would '
'like this string prepended to the generated Dart file. \n\n'
'Alternatively, see the `header-file` option to pass in a text '
'file for longer headers.'
);
parser.addOption(
'header-file',
help: 'The header to prepend to the generated Dart localizations '
'files. The value of this option is the name of the file that '
'contains the header text. \n\n'
'Alternatively, see the `header` option to pass in a string '
'for a simpler header.'
);
final argslib.ArgResults results = parser.parse(arguments);
if (results['help'] == true) {
@@ -70,6 +87,8 @@ Future<void> main(List<String> arguments) async {
final String templateArbFileName = results['template-arb-file'] as String;
final String classNameString = results['output-class'] as String;
final String preferredSupportedLocaleString = results['preferred-supported-locales'] as String;
final String headerString = results['header'] as String;
final String headerFile = results['header-file'] as String;
const local.LocalFileSystem fs = local.LocalFileSystem();
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);
@@ -82,6 +101,8 @@ Future<void> main(List<String> arguments) async {
outputFileString: outputFileString,
classNameString: classNameString,
preferredSupportedLocaleString: preferredSupportedLocaleString,
headerString: headerString,
headerFile: headerFile,
)
..loadResources()
..writeOutputFile();