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

[gen-l10n] Fix forwarding of output-dir in l10n.yaml file (#71128)

parent bb29c88a
...@@ -43,7 +43,7 @@ void generateLocalizations({ ...@@ -43,7 +43,7 @@ void generateLocalizations({
precacheLanguageAndRegionTags(); precacheLanguageAndRegionTags();
final String inputPathString = options?.arbDirectory?.toFilePath() ?? globals.fs.path.join('lib', 'l10n'); final String inputPathString = options?.arbDirectory?.path ?? globals.fs.path.join('lib', 'l10n');
final String templateArbFileName = options?.templateArbFile?.toFilePath() ?? 'app_en.arb'; final String templateArbFileName = options?.templateArbFile?.toFilePath() ?? 'app_en.arb';
final String outputFileString = options?.outputLocalizationsFile?.toFilePath() ?? 'app_localizations.dart'; final String outputFileString = options?.outputLocalizationsFile?.toFilePath() ?? 'app_localizations.dart';
...@@ -55,6 +55,7 @@ void generateLocalizations({ ...@@ -55,6 +55,7 @@ void generateLocalizations({
inputPathString: inputPathString, inputPathString: inputPathString,
templateArbFileName: templateArbFileName, templateArbFileName: templateArbFileName,
outputFileString: outputFileString, outputFileString: outputFileString,
outputPathString: options?.outputDirectory?.path,
classNameString: options.outputClass ?? 'AppLocalizations', classNameString: options.outputClass ?? 'AppLocalizations',
preferredSupportedLocale: options.preferredSupportedLocales, preferredSupportedLocale: options.preferredSupportedLocales,
headerString: options.header, headerString: options.header,
...@@ -155,6 +156,7 @@ class LocalizationOptions { ...@@ -155,6 +156,7 @@ class LocalizationOptions {
this.untranslatedMessagesFile, this.untranslatedMessagesFile,
this.header, this.header,
this.outputClass, this.outputClass,
this.outputDirectory,
this.preferredSupportedLocales, this.preferredSupportedLocales,
this.headerFile, this.headerFile,
this.deferredLoading, this.deferredLoading,
...@@ -164,7 +166,7 @@ class LocalizationOptions { ...@@ -164,7 +166,7 @@ class LocalizationOptions {
/// The `--arb-dir` argument. /// The `--arb-dir` argument.
/// ///
/// The directory where all localization files should reside. /// The directory where all input localization files should reside.
final Uri arbDirectory; final Uri arbDirectory;
/// The `--template-arb-file` argument. /// The `--template-arb-file` argument.
...@@ -190,6 +192,11 @@ class LocalizationOptions { ...@@ -190,6 +192,11 @@ class LocalizationOptions {
/// The `--output-class` argument. /// The `--output-class` argument.
final String outputClass; final String outputClass;
/// The `--output-dir` argument.
///
/// The directory where all output localization files should be generated.
final Uri outputDirectory;
/// The `--preferred-supported-locales` argument. /// The `--preferred-supported-locales` argument.
final List<String> preferredSupportedLocales; final List<String> preferredSupportedLocales;
...@@ -244,6 +251,7 @@ LocalizationOptions parseLocalizationsOptions({ ...@@ -244,6 +251,7 @@ LocalizationOptions parseLocalizationsOptions({
untranslatedMessagesFile: _tryReadUri(yamlMap, 'untranslated-messages-file', logger), untranslatedMessagesFile: _tryReadUri(yamlMap, 'untranslated-messages-file', logger),
header: _tryReadString(yamlMap, 'header', logger), header: _tryReadString(yamlMap, 'header', logger),
outputClass: _tryReadString(yamlMap, 'output-class', logger), outputClass: _tryReadString(yamlMap, 'output-class', logger),
outputDirectory: _tryReadUri(yamlMap, 'output-dir', logger),
preferredSupportedLocales: _tryReadStringList(yamlMap, 'preferred-supported-locales', logger), preferredSupportedLocales: _tryReadStringList(yamlMap, 'preferred-supported-locales', logger),
headerFile: _tryReadUri(yamlMap, 'header-file', logger), headerFile: _tryReadUri(yamlMap, 'header-file', logger),
deferredLoading: _tryReadBool(yamlMap, 'use-deferred-loading', logger), deferredLoading: _tryReadBool(yamlMap, 'use-deferred-loading', logger),
......
...@@ -35,6 +35,7 @@ void main() { ...@@ -35,6 +35,7 @@ void main() {
deferredLoading: true, deferredLoading: true,
outputClass: 'Foo', outputClass: 'Foo',
outputLocalizationsFile: Uri.file('bar'), outputLocalizationsFile: Uri.file('bar'),
outputDirectory: Uri.directory(fileSystem.path.join('lib', 'l10n')),
preferredSupportedLocales: <String>['en_US'], preferredSupportedLocales: <String>['en_US'],
templateArbFile: Uri.file('example.arb'), templateArbFile: Uri.file('example.arb'),
untranslatedMessagesFile: Uri.file('untranslated'), untranslatedMessagesFile: Uri.file('untranslated'),
...@@ -50,11 +51,10 @@ void main() { ...@@ -50,11 +51,10 @@ void main() {
projectDir: fileSystem.currentDirectory, projectDir: fileSystem.currentDirectory,
dependenciesDir: fileSystem.currentDirectory, dependenciesDir: fileSystem.currentDirectory,
); );
verify( verify(
mockLocalizationsGenerator.initialize( mockLocalizationsGenerator.initialize(
inputPathString: 'arb', inputPathString: 'arb',
outputPathString: null, outputPathString: fileSystem.path.join('lib', 'l10n/'),
templateArbFileName: 'example.arb', templateArbFileName: 'example.arb',
outputFileString: 'bar', outputFileString: 'bar',
classNameString: 'Foo', classNameString: 'Foo',
......
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