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

make app localizations lookup a public method (#84732)

parent aeca5c95
...@@ -541,11 +541,11 @@ String _generateDelegateClass({ ...@@ -541,11 +541,11 @@ String _generateDelegateClass({
useDeferredLoading ? loadBodyDeferredLoadingTemplate : loadBodyTemplate useDeferredLoading ? loadBodyDeferredLoadingTemplate : loadBodyTemplate
) )
.replaceAll('@(class)', className) .replaceAll('@(class)', className)
.replaceAll('@(lookupName)', '_lookup$className'); .replaceAll('@(lookupName)', 'lookup$className');
final String lookupFunction = (useDeferredLoading ? final String lookupFunction = (useDeferredLoading ?
lookupFunctionDeferredLoadingTemplate : lookupFunctionTemplate) lookupFunctionDeferredLoadingTemplate : lookupFunctionTemplate)
.replaceAll('@(class)', className) .replaceAll('@(class)', className)
.replaceAll('@(lookupName)', '_lookup$className') .replaceAll('@(lookupName)', 'lookup$className')
.replaceAll('@(lookupBody)', lookupBody); .replaceAll('@(lookupBody)', lookupBody);
return delegateClassTemplate return delegateClassTemplate
.replaceAll('@(class)', className) .replaceAll('@(class)', className)
......
...@@ -2449,4 +2449,30 @@ String orderNumber(int number) { ...@@ -2449,4 +2449,30 @@ String orderNumber(int number) {
''')); '''));
expect(localizationsFile, isNot(contains(intlImportDartCode))); expect(localizationsFile, isNot(contains(intlImportDartCode)));
}); });
testWithoutContext('app localizations lookup is a public method', () {
final Directory l10nDirectory = fs.currentDirectory.childDirectory('lib').childDirectory('l10n')
..createSync(recursive: true);
l10nDirectory.childFile(defaultTemplateArbFileName)
.writeAsStringSync(singleMessageArbFileString);
LocalizationsGenerator(
fileSystem: fs,
inputPathString: defaultL10nPathString,
outputPathString: defaultL10nPathString,
templateArbFileName: defaultTemplateArbFileName,
outputFileString: defaultOutputFileString,
classNameString: defaultClassNameString,
)
..loadResources()
..writeOutputFiles(BufferLogger.test());
final String localizationsFile = fs.file(
fs.path.join(syntheticL10nPackagePath, 'output-localization-file.dart'),
).readAsStringSync();
print(localizationsFile);
expect(localizationsFile, containsIgnoringWhitespace(r'''
AppLocalizations lookupAppLocalizations(Locale locale) {
'''));
});
} }
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