forked from firka/flutter
Support preferred locales for gen_l10n (#47845)
* Add preferred-supported-locales option to gen_l10n.dart executable
This commit is contained in:
@@ -46,6 +46,15 @@ Future<void> main(List<String> arguments) async {
|
||||
help: 'The Dart class name to use for the output localization and '
|
||||
'localizations delegate classes.',
|
||||
);
|
||||
parser.addOption(
|
||||
'preferred-supported-locales',
|
||||
help: 'The list of preferred supported locales for the application. '
|
||||
'By default, the tool will generate the supported locales list in '
|
||||
'alphabetical order. Use this flag if you would like to default to '
|
||||
'a different locale. \n\n'
|
||||
'For example, pass in [\'en_US\'] if you would like your app to '
|
||||
'default to American English if a device supports it.',
|
||||
);
|
||||
|
||||
final argslib.ArgResults results = parser.parse(arguments);
|
||||
if (results['help'] == true) {
|
||||
@@ -57,6 +66,7 @@ Future<void> main(List<String> arguments) async {
|
||||
final String outputFileString = results['output-localization-file'] as String;
|
||||
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;
|
||||
|
||||
const local.LocalFileSystem fs = local.LocalFileSystem();
|
||||
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);
|
||||
@@ -67,6 +77,7 @@ Future<void> main(List<String> arguments) async {
|
||||
templateArbFileName: templateArbFileName,
|
||||
outputFileString: outputFileString,
|
||||
classNameString: classNameString,
|
||||
preferredSupportedLocaleString: preferredSupportedLocaleString,
|
||||
)
|
||||
..parseArbFiles()
|
||||
..generateClassMethods()
|
||||
|
||||
Reference in New Issue
Block a user