Unverified Commit 13501af6 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[gen_l10n] Optionally generate list of inputs/outputs (#56490)

parent 8f7b2f9b
...@@ -105,6 +105,21 @@ void main(List<String> arguments) { ...@@ -105,6 +105,21 @@ void main(List<String> arguments) {
'Note that this flag does not affect other platforms such as mobile or ' 'Note that this flag does not affect other platforms such as mobile or '
'desktop.', 'desktop.',
); );
parser.addOption(
'gen-inputs-and-outputs-list',
valueHelp: 'path-to-output-directory',
help: 'When specified, the tool generates a JSON file containing the '
'tool\'s inputs and outputs named gen_l10n_inputs_and_outputs.json.'
'\n\n'
'This can be useful for keeping track of which files of the Flutter '
'project were used when generating the latest set of localizations. '
'For example, the Flutter tool\'s build system uses this file to '
'keep track of when to call gen_l10n during hot reload.\n\n'
'The value of this option is the directory where the JSON file will be '
'generated.'
'\n\n'
'When null, the JSON file will not be generated.'
);
final argslib.ArgResults results = parser.parse(arguments); final argslib.ArgResults results = parser.parse(arguments);
if (results['help'] == true) { if (results['help'] == true) {
...@@ -124,6 +139,7 @@ void main(List<String> arguments) { ...@@ -124,6 +139,7 @@ void main(List<String> arguments) {
final String headerString = results['header'] as String; final String headerString = results['header'] as String;
final String headerFile = results['header-file'] as String; final String headerFile = results['header-file'] as String;
final bool useDeferredLoading = results['use-deferred-loading'] as bool; final bool useDeferredLoading = results['use-deferred-loading'] as bool;
final String inputsAndOutputsListPath = results['gen-inputs-and-outputs-list'] as String;
const local.LocalFileSystem fs = local.LocalFileSystem(); const local.LocalFileSystem fs = local.LocalFileSystem();
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs); final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);
...@@ -140,9 +156,10 @@ void main(List<String> arguments) { ...@@ -140,9 +156,10 @@ void main(List<String> arguments) {
headerString: headerString, headerString: headerString,
headerFile: headerFile, headerFile: headerFile,
useDeferredLoading: useDeferredLoading, useDeferredLoading: useDeferredLoading,
inputsAndOutputsListPath: inputsAndOutputsListPath,
) )
..loadResources() ..loadResources()
..writeOutputFile() ..writeOutputFiles()
..outputUnimplementedMessages(untranslatedMessagesFile); ..outputUnimplementedMessages(untranslatedMessagesFile);
} on FileSystemException catch (e) { } on FileSystemException catch (e) {
exitWithError(e.message); exitWithError(e.message);
......
...@@ -418,11 +418,13 @@ class LocalizationsGenerator { ...@@ -418,11 +418,13 @@ class LocalizationsGenerator {
/// This file is specified with the [initialize] method. /// This file is specified with the [initialize] method.
File templateArbFile; File templateArbFile;
/// The file to write the generated localizations and localizations delegate /// The file to write the generated abstract localizations and
/// classes to. /// localizations delegate classes to. Separate localizations
/// files will also be generated for each language using this
/// filename as a prefix and the locale as the suffix.
/// ///
/// This file is specified with the [initialize] method. /// This file is specified with the [initialize] method.
File outputFile; File baseOutputFile;
/// The class name to be used for the localizations class in [outputFile]. /// The class name to be used for the localizations class in [outputFile].
/// ///
...@@ -491,6 +493,12 @@ class LocalizationsGenerator { ...@@ -491,6 +493,12 @@ class LocalizationsGenerator {
/// classes. /// classes.
String _generatedLocalizationsFile; String _generatedLocalizationsFile;
/// The file that contains the list of inputs and outputs for generating
/// localizations.
File _inputsAndOutputsListFile;
List<String> _inputFileList;
List<String> _outputFileList;
/// Initializes [inputDirectory], [outputDirectory], [templateArbFile], /// Initializes [inputDirectory], [outputDirectory], [templateArbFile],
/// [outputFile] and [className]. /// [outputFile] and [className].
/// ///
...@@ -509,15 +517,17 @@ class LocalizationsGenerator { ...@@ -509,15 +517,17 @@ class LocalizationsGenerator {
String headerString, String headerString,
String headerFile, String headerFile,
bool useDeferredLoading = false, bool useDeferredLoading = false,
String inputsAndOutputsListPath,
}) { }) {
setInputDirectory(inputPathString); setInputDirectory(inputPathString);
setOutputDirectory(outputPathString ?? inputPathString); setOutputDirectory(outputPathString ?? inputPathString);
setTemplateArbFile(templateArbFileName); setTemplateArbFile(templateArbFileName);
setOutputFile(outputFileString); setBaseOutputFile(outputFileString);
setPreferredSupportedLocales(preferredSupportedLocaleString); setPreferredSupportedLocales(preferredSupportedLocaleString);
_setHeader(headerString, headerFile); _setHeader(headerString, headerFile);
_setUseDeferredLoading(useDeferredLoading); _setUseDeferredLoading(useDeferredLoading);
className = classNameString; className = classNameString;
_setInputsAndOutputsListFile(inputsAndOutputsListPath);
} }
static bool _isNotReadable(FileStat fileStat) { static bool _isNotReadable(FileStat fileStat) {
...@@ -581,10 +591,10 @@ class LocalizationsGenerator { ...@@ -581,10 +591,10 @@ class LocalizationsGenerator {
/// Sets the reference [File] for the localizations delegate [outputFile]. /// Sets the reference [File] for the localizations delegate [outputFile].
@visibleForTesting @visibleForTesting
void setOutputFile(String outputFileString) { void setBaseOutputFile(String outputFileString) {
if (outputFileString == null) if (outputFileString == null)
throw L10nException('outputFileString argument cannot be null'); throw L10nException('outputFileString argument cannot be null');
outputFile = _fs.file(path.join(outputDirectory.path, outputFileString)); baseOutputFile = _fs.file(path.join(outputDirectory.path, outputFileString));
} }
static bool _isValidClassName(String className) { static bool _isValidClassName(String className) {
...@@ -664,6 +674,17 @@ class LocalizationsGenerator { ...@@ -664,6 +674,17 @@ class LocalizationsGenerator {
_useDeferredLoading = useDeferredLoading; _useDeferredLoading = useDeferredLoading;
} }
void _setInputsAndOutputsListFile(String inputsAndOutputsListPath) {
if (inputsAndOutputsListPath == null)
return;
_inputsAndOutputsListFile = _fs.file(
path.join(inputsAndOutputsListPath, 'gen_l10n_inputs_and_outputs.json'),
);
_inputFileList = <String>[];
_outputFileList = <String>[];
}
static bool _isValidGetterAndMethodName(String name) { static bool _isValidGetterAndMethodName(String name) {
// Public Dart method name must not start with an underscore // Public Dart method name must not start with an underscore
if (name[0] == '_') if (name[0] == '_')
...@@ -697,6 +718,11 @@ class LocalizationsGenerator { ...@@ -697,6 +718,11 @@ class LocalizationsGenerator {
} }
_allBundles = AppResourceBundleCollection(inputDirectory); _allBundles = AppResourceBundleCollection(inputDirectory);
if (_inputsAndOutputsListFile != null) {
_inputFileList.addAll(_allBundles.bundles.map((AppResourceBundle bundle) {
return bundle.file.absolute.path;
}));
}
final List<LocaleInfo> allLocales = List<LocaleInfo>.from(_allBundles.locales); final List<LocaleInfo> allLocales = List<LocaleInfo>.from(_allBundles.locales);
for (final LocaleInfo preferredLocale in preferredSupportedLocales) { for (final LocaleInfo preferredLocale in preferredSupportedLocales) {
...@@ -781,8 +807,9 @@ class LocalizationsGenerator { ...@@ -781,8 +807,9 @@ class LocalizationsGenerator {
} }
// Generate the AppLocalizations class, its LocalizationsDelegate subclass, // Generate the AppLocalizations class, its LocalizationsDelegate subclass,
// and all AppLocalizations subclasses for every locale. // and all AppLocalizations subclasses for every locale. This method by
void generateCode() { // itself does not generate the output files.
void _generateCode() {
bool isBaseClassLocale(LocaleInfo locale, String language) { bool isBaseClassLocale(LocaleInfo locale, String language) {
return locale.languageCode == language return locale.languageCode == language
&& locale.countryCode == null && locale.countryCode == null
...@@ -800,7 +827,7 @@ class LocalizationsGenerator { ...@@ -800,7 +827,7 @@ class LocalizationsGenerator {
} }
final String directory = path.basename(outputDirectory.path); final String directory = path.basename(outputDirectory.path);
final String outputFileName = path.basename(outputFile.path); final String outputFileName = path.basename(baseOutputFile.path);
final Iterable<String> supportedLocalesCode = supportedLocales.map((LocaleInfo locale) { final Iterable<String> supportedLocalesCode = supportedLocales.map((LocaleInfo locale) {
final String languageCode = locale.languageCode; final String languageCode = locale.languageCode;
...@@ -892,9 +919,9 @@ class LocalizationsGenerator { ...@@ -892,9 +919,9 @@ class LocalizationsGenerator {
.replaceAll('@(delegateClass)', delegateClass); .replaceAll('@(delegateClass)', delegateClass);
} }
void writeOutputFile() { void writeOutputFiles() {
// First, generate the string contents of all necessary files. // First, generate the string contents of all necessary files.
generateCode(); _generateCode();
// Since all validity checks have passed up to this point, // Since all validity checks have passed up to this point,
// write the contents into the directory. // write the contents into the directory.
...@@ -913,8 +940,27 @@ class LocalizationsGenerator { ...@@ -913,8 +940,27 @@ class LocalizationsGenerator {
// Generate the required files for localizations. // Generate the required files for localizations.
_languageFileMap.forEach((File file, String contents) { _languageFileMap.forEach((File file, String contents) {
file.writeAsStringSync(contents); file.writeAsStringSync(contents);
if (_inputsAndOutputsListFile != null) {
_outputFileList.add(file.absolute.path);
}
}); });
outputFile.writeAsStringSync(_generatedLocalizationsFile);
baseOutputFile.writeAsStringSync(_generatedLocalizationsFile);
if (_inputsAndOutputsListFile != null) {
_outputFileList.add(baseOutputFile.absolute.path);
// Generate a JSON file containing the inputs and outputs of the gen_l10n script.
if (!_inputsAndOutputsListFile.existsSync()) {
_inputsAndOutputsListFile.createSync(recursive: true);
}
_inputsAndOutputsListFile.writeAsStringSync(
json.encode(<String, Object> {
'inputs': _inputFileList,
'outputs': _outputFileList,
}),
);
}
} }
void outputUnimplementedMessages(String untranslatedMessagesFile) { void outputUnimplementedMessages(String untranslatedMessagesFile) {
......
...@@ -77,7 +77,7 @@ void main() { ...@@ -77,7 +77,7 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setInputDirectory should fail if the ' 'LocalizationsGenerator.setInputDirectory should fail if the '
'directory does not exist.' 'directory does not exist.'
); );
}); });
...@@ -93,8 +93,8 @@ void main() { ...@@ -93,8 +93,8 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setInputDirectory should fail if the ' 'LocalizationsGenerator.setInputDirectory should fail if the '
'the input string is null.' 'input string is null.'
); );
}); });
...@@ -109,8 +109,8 @@ void main() { ...@@ -109,8 +109,8 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setOutputDirectory should fail if the ' 'LocalizationsGenerator.setOutputDirectory should fail if the '
'the input string is null.' 'input string is null.'
); );
}); });
...@@ -124,8 +124,8 @@ void main() { ...@@ -124,8 +124,8 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setTemplateArbFile should fail if the ' 'LocalizationsGenerator.setTemplateArbFile should fail if the '
'the inputDirectory is not specified.' 'inputDirectory is not specified.'
); );
}); });
...@@ -140,8 +140,8 @@ void main() { ...@@ -140,8 +140,8 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setTemplateArbFile should fail if the ' 'LocalizationsGenerator.setTemplateArbFile should fail if the '
'the templateArbFileName passed in is null.' 'templateArbFileName passed in is null.'
); );
}); });
...@@ -156,24 +156,24 @@ void main() { ...@@ -156,24 +156,24 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setTemplateArbFile should fail if the ' 'LocalizationsGenerator.setTemplateArbFile should fail if the '
'the input string is null.' 'input string is null.'
); );
}); });
test('setOutputFile fails if input string is null', () { test('setBaseOutputFile fails if input string is null', () {
_standardFlutterDirectoryL10nSetup(fs); _standardFlutterDirectoryL10nSetup(fs);
final LocalizationsGenerator generator = LocalizationsGenerator(fs); final LocalizationsGenerator generator = LocalizationsGenerator(fs);
try { try {
generator.setOutputFile(null); generator.setBaseOutputFile(null);
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('cannot be null')); expect(e.message, contains('cannot be null'));
return; return;
} }
fail( fail(
'Attempting to set LocalizationsGenerator.setOutputFile should fail if the ' 'LocalizationsGenerator.setBaseOutputFile should fail if the '
'the input string is null.' 'input string is null.'
); );
}); });
...@@ -188,8 +188,8 @@ void main() { ...@@ -188,8 +188,8 @@ void main() {
} }
fail( fail(
'Attempting to set LocalizationsGenerator.className should fail if the ' 'LocalizationsGenerator.className should fail if the '
'the input string is null.' 'input string is null.'
); );
}); });
...@@ -202,7 +202,7 @@ void main() { ...@@ -202,7 +202,7 @@ void main() {
generator.setInputDirectory(defaultL10nPathString); generator.setInputDirectory(defaultL10nPathString);
generator.setOutputDirectory(defaultL10nPathString); generator.setOutputDirectory(defaultL10nPathString);
generator.setTemplateArbFile(defaultTemplateArbFileName); generator.setTemplateArbFile(defaultTemplateArbFileName);
generator.setOutputFile(defaultOutputFileString); generator.setBaseOutputFile(defaultOutputFileString);
} on L10nException catch (e) { } on L10nException catch (e) {
throw TestFailure('Unexpected failure during test setup: ${e.message}'); throw TestFailure('Unexpected failure during test setup: ${e.message}');
} }
...@@ -216,8 +216,8 @@ void main() { ...@@ -216,8 +216,8 @@ void main() {
return; return;
} }
fail( fail(
'Attempting to set LocalizationsGenerator.className should fail if the ' 'LocalizationsGenerator.className should fail if the '
'the input string is not a valid Dart class name.' 'input string is not a valid Dart class name.'
); );
}); });
...@@ -229,8 +229,8 @@ void main() { ...@@ -229,8 +229,8 @@ void main() {
return; return;
} }
fail( fail(
'Attempting to set LocalizationsGenerator.className should fail if the ' 'LocalizationsGenerator.className should fail if the '
'the input string is not a valid public Dart class name.' 'input string is not a valid public Dart class name.'
); );
}); });
...@@ -242,8 +242,8 @@ void main() { ...@@ -242,8 +242,8 @@ void main() {
return; return;
} }
fail( fail(
'Attempting to set LocalizationsGenerator.className should fail if the ' 'LocalizationsGenerator.className should fail if the '
'the input string is not a valid public Dart class name.' 'input string is not a valid public Dart class name.'
); );
}); });
...@@ -255,8 +255,8 @@ void main() { ...@@ -255,8 +255,8 @@ void main() {
return; return;
} }
fail( fail(
'Attempting to set LocalizationsGenerator.className should fail if the ' 'LocalizationsGenerator.className should fail if the '
'the input string is not a valid public Dart class name.' 'input string is not a valid public Dart class name.'
); );
}); });
}); });
...@@ -326,7 +326,7 @@ void main() { ...@@ -326,7 +326,7 @@ void main() {
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
) )
..loadResources() ..loadResources()
..generateCode() ..writeOutputFiles()
..outputUnimplementedMessages(path.join('lib', 'l10n', 'unimplemented_message_translations.json')); ..outputUnimplementedMessages(path.join('lib', 'l10n', 'unimplemented_message_translations.json'));
} on L10nException catch (e) { } on L10nException catch (e) {
fail('Generating output should not fail: \n${e.message}'); fail('Generating output should not fail: \n${e.message}');
...@@ -359,7 +359,7 @@ void main() { ...@@ -359,7 +359,7 @@ void main() {
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
) )
..loadResources() ..loadResources()
..writeOutputFile(); ..writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
fail('Generating output should not fail: \n${e.message}'); fail('Generating output should not fail: \n${e.message}');
} }
...@@ -397,7 +397,7 @@ void main() { ...@@ -397,7 +397,7 @@ void main() {
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
) )
..loadResources() ..loadResources()
..writeOutputFile(); ..writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
fail('Generating output should not fail: \n${e.message}'); fail('Generating output should not fail: \n${e.message}');
} }
...@@ -424,7 +424,7 @@ void main() { ...@@ -424,7 +424,7 @@ void main() {
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
) )
..loadResources() ..loadResources()
..writeOutputFile(); ..writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
fail('Generating output should not fail: \n${e.message}'); fail('Generating output should not fail: \n${e.message}');
} }
...@@ -436,6 +436,45 @@ void main() { ...@@ -436,6 +436,45 @@ void main() {
expect(outputDirectory.childFile('output-localization-file_es.dart').existsSync(), isTrue); expect(outputDirectory.childFile('output-localization-file_es.dart').existsSync(), isTrue);
}); });
test('creates list of inputs and outputs when file path is specified', () {
_standardFlutterDirectoryL10nSetup(fs);
LocalizationsGenerator generator;
try {
generator = LocalizationsGenerator(fs);
generator
..initialize(
inputPathString: defaultL10nPathString,
templateArbFileName: defaultTemplateArbFileName,
outputFileString: defaultOutputFileString,
classNameString: defaultClassNameString,
inputsAndOutputsListPath: defaultL10nPathString,
)
..loadResources()
..writeOutputFiles();
} on L10nException catch (e) {
fail('Generating output should not fail: \n${e.message}');
}
final File inputsAndOutputsList = fs
.directory('lib')
.childDirectory('l10n')
.childFile('gen_l10n_inputs_and_outputs.json');
expect(inputsAndOutputsList.existsSync(), isTrue);
final Map<String, dynamic> jsonResult = json.decode(inputsAndOutputsList.readAsStringSync()) as Map<String, dynamic>;
expect(jsonResult.containsKey('inputs'), isTrue);
final List<dynamic> inputList = jsonResult['inputs'] as List<dynamic>;
expect(inputList, contains(fs.path.absolute('lib', 'l10n', 'app_en.arb')));
expect(inputList, contains(fs.path.absolute('lib', 'l10n', 'app_es.arb')));
expect(jsonResult.containsKey('outputs'), isTrue);
final List<dynamic> outputList = jsonResult['outputs'] as List<dynamic>;
expect(outputList, contains(fs.path.absolute('lib', 'l10n', 'output-localization-file.dart')));
expect(outputList, contains(fs.path.absolute('lib', 'l10n', 'output-localization-file_en.dart')));
expect(outputList, contains(fs.path.absolute('lib', 'l10n', 'output-localization-file_es.dart')));
});
test('setting both a headerString and a headerFile should fail', () { test('setting both a headerString and a headerFile should fail', () {
fs.currentDirectory.childDirectory('lib').childDirectory('l10n') fs.currentDirectory.childDirectory('lib').childDirectory('l10n')
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -710,15 +749,9 @@ void main() { ...@@ -710,15 +749,9 @@ void main() {
fail('Setting language and locales should not fail: \n${e.message}'); fail('Setting language and locales should not fail: \n${e.message}');
} }
if (Platform.isWindows) { expect(generator.arbPathStrings.first, path.join('lib', 'l10n', 'app_en.arb'));
expect(generator.arbPathStrings.first, r'lib\l10n\app_en.arb'); expect(generator.arbPathStrings.elementAt(1), path.join('lib', 'l10n', 'app_es.arb'));
expect(generator.arbPathStrings.elementAt(1), r'lib\l10n\app_es.arb'); expect(generator.arbPathStrings.elementAt(2), path.join('lib', 'l10n', 'app_zh.arb'));
expect(generator.arbPathStrings.elementAt(2), r'lib\l10n\app_zh.arb');
} else {
expect(generator.arbPathStrings.first, 'lib/l10n/app_en.arb');
expect(generator.arbPathStrings.elementAt(1), 'lib/l10n/app_es.arb');
expect(generator.arbPathStrings.elementAt(2), 'lib/l10n/app_zh.arb');
}
}); });
test('correctly parses @@locale property in arb file', () { test('correctly parses @@locale property in arb file', () {
...@@ -904,7 +937,7 @@ void main() { ...@@ -904,7 +937,7 @@ void main() {
}); });
}); });
group('generateCode', () { group('writeOutputFiles', () {
test('should generate a file per language', () { test('should generate a file per language', () {
const String singleEnCaMessageArbFileString = ''' const String singleEnCaMessageArbFileString = '''
{ {
...@@ -924,7 +957,7 @@ void main() { ...@@ -924,7 +957,7 @@ void main() {
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.writeOutputFile(); generator.writeOutputFiles();
} on Exception catch (e) { } on Exception catch (e) {
fail('Generating output files should not fail: $e'); fail('Generating output files should not fail: $e');
} }
...@@ -957,7 +990,7 @@ void main() { ...@@ -957,7 +990,7 @@ void main() {
preferredSupportedLocaleString: preferredSupportedLocaleString, preferredSupportedLocaleString: preferredSupportedLocaleString,
); );
generator.loadResources(); generator.loadResources();
generator.writeOutputFile(); generator.writeOutputFiles();
} on Exception catch (e) { } on Exception catch (e) {
fail('Generating output files should not fail: $e'); fail('Generating output files should not fail: $e');
} }
...@@ -988,7 +1021,7 @@ import 'output-localization-file_zh.dart'; ...@@ -988,7 +1021,7 @@ import 'output-localization-file_zh.dart';
useDeferredLoading: true, useDeferredLoading: true,
); );
generator.loadResources(); generator.loadResources();
generator.writeOutputFile(); generator.writeOutputFiles();
} on Exception catch (e) { } on Exception catch (e) {
fail('Generating output files should not fail: $e'); fail('Generating output files should not fail: $e');
} }
...@@ -1033,7 +1066,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1033,7 +1066,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('asdf')); expect(e.message, contains('asdf'));
expect(e.message, contains('springStartDate')); expect(e.message, contains('springStartDate'));
...@@ -1072,7 +1105,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1072,7 +1105,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('the "format" attribute needs to be set')); expect(e.message, contains('the "format" attribute needs to be set'));
return; return;
...@@ -1110,7 +1143,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1110,7 +1143,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('asdf')); expect(e.message, contains('asdf'));
expect(e.message, contains('progress')); expect(e.message, contains('progress'));
...@@ -1147,7 +1180,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1147,7 +1180,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Check to see if the plural message is in the proper ICU syntax format')); expect(e.message, contains('Check to see if the plural message is in the proper ICU syntax format'));
return; return;
...@@ -1180,7 +1213,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1180,7 +1213,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Check to see if the plural message is in the proper ICU syntax format')); expect(e.message, contains('Check to see if the plural message is in the proper ICU syntax format'));
return; return;
...@@ -1209,7 +1242,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1209,7 +1242,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Resource attribute "@helloWorlds" was not found')); expect(e.message, contains('Resource attribute "@helloWorlds" was not found'));
return; return;
...@@ -1241,7 +1274,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1241,7 +1274,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('is not properly formatted')); expect(e.message, contains('is not properly formatted'));
expect(e.message, contains('Ensure that it is a map with string valued keys')); expect(e.message, contains('Ensure that it is a map with string valued keys'));
...@@ -1274,7 +1307,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1274,7 +1307,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on FormatException catch (e) { } on FormatException catch (e) {
expect(e.message, contains('Unexpected character')); expect(e.message, contains('Unexpected character'));
return; return;
...@@ -1306,7 +1339,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1306,7 +1339,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Resource attribute "@title" was not found')); expect(e.message, contains('Resource attribute "@title" was not found'));
return; return;
...@@ -1342,7 +1375,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1342,7 +1375,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Invalid ARB resource name')); expect(e.message, contains('Invalid ARB resource name'));
return; return;
...@@ -1374,7 +1407,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1374,7 +1407,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Invalid ARB resource name')); expect(e.message, contains('Invalid ARB resource name'));
return; return;
...@@ -1406,7 +1439,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e ...@@ -1406,7 +1439,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
classNameString: defaultClassNameString, classNameString: defaultClassNameString,
); );
generator.loadResources(); generator.loadResources();
generator.generateCode(); generator.writeOutputFiles();
} on L10nException catch (e) { } on L10nException catch (e) {
expect(e.message, contains('Invalid ARB resource name')); expect(e.message, contains('Invalid ARB resource name'));
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment