diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index b6c4ab1784..4456bdcfb7 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -94,12 +94,12 @@ Future _verifyInternationalizations() async { final EvalResult genResult = await _evalCommand( dart, [ - path.join('dev', 'tools', 'gen_localizations.dart'), + path.join('dev', 'tools', 'localization', 'gen_localizations.dart'), ], workingDirectory: flutterRoot, ); - final String localizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'localizations.dart'); + final String localizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); final String expectedResult = await File(localizationsFile).readAsString(); if (genResult.stdout.trim() != expectedResult.trim()) { diff --git a/dev/tools/gen_date_localizations.dart b/dev/tools/localization/gen_date_localizations.dart similarity index 93% rename from dev/tools/gen_date_localizations.dart rename to dev/tools/localization/gen_date_localizations.dart index b60ffecda6..7e0c3276e0 100644 --- a/dev/tools/gen_date_localizations.dart +++ b/dev/tools/localization/gen_date_localizations.dart @@ -7,7 +7,7 @@ /// package. /// /// The extracted data is written into: -/// packages/flutter_localizations/lib/src/l10n/date_localizations.dart +/// packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart /// /// ## Usage /// @@ -16,14 +16,14 @@ /// The following outputs the generated Dart code to the console as a dry run: /// /// ``` -/// dart dev/tools/gen_date_localizations.dart +/// dart dev/tools/localization/gen_date_localizations.dart /// ``` /// /// If the data looks good, use the `--overwrite` option to overwrite the /// lib/src/l10n/date_localizations.dart file: /// /// ``` -/// dart dev/tools/gen_date_localizations.dart --overwrite +/// dart dev/tools/localization/gen_date_localizations.dart --overwrite /// ``` import 'dart:async'; @@ -79,7 +79,7 @@ Future main(List rawArgs) async { // This file has been automatically generated. Please do not edit it manually. // To regenerate run (omit --overwrite to print to console instead of the file): -// dart --enable-asserts dev/tools/gen_date_localizations.dart --overwrite +// dart --enable-asserts dev/tools/localization/gen_date_localizations.dart --overwrite ''' ); @@ -113,7 +113,7 @@ Future main(List rawArgs) async { buffer.writeln('};'); if (writeToFile) { - final File dateLocalizationsFile = File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'date_localizations.dart')); + final File dateLocalizationsFile = File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_date_localizations.dart')); dateLocalizationsFile.writeAsStringSync(buffer.toString()); Process.runSync(path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartfmt'), [ '-w', diff --git a/dev/tools/gen_localizations.dart b/dev/tools/localization/gen_localizations.dart similarity index 94% rename from dev/tools/gen_localizations.dart rename to dev/tools/localization/gen_localizations.dart index 8b3007b6bc..bc54f31593 100644 --- a/dev/tools/gen_localizations.dart +++ b/dev/tools/localization/gen_localizations.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This program generates a getTranslation() function that looks up the -// translations contained by the arb files. The returned value is an +// This program generates a getMaterialTranslation() function that looks up the +// translations provided by the arb files. The returned value is a generated // instance of GlobalMaterialLocalizations that corresponds to a single // locale. // @@ -28,14 +28,14 @@ // The following outputs the generated Dart code to the console as a dry run: // // ``` -// dart dev/tools/gen_localizations.dart +// dart dev/tools/localization/gen_localizations.dart // ``` // // If the data looks good, use the `-w` or `--overwrite` option to overwrite the -// packages/flutter_localizations/lib/src/l10n/localizations.dart file: +// packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart file: // // ``` -// dart dev/tools/gen_localizations.dart --overwrite +// dart dev/tools/localization/gen_localizations.dart --overwrite // ``` import 'dart:async'; @@ -144,9 +144,9 @@ String generateTranslationBundles() { // The classes defined here encode all of the translations found in the // `flutter_localizations/lib/src/l10n/*.arb` files. // -// These classes are constructed by the [getTranslation] method at the bottom of -// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined -// in `flutter_localizations/lib/src/material_localizations.dart`.'''); +// These classes are constructed by the [getMaterialTranslation] method at the +// bottom of this file, and used by the [_MaterialLocalizationsDelegate.load] +// method defined in `flutter_localizations/lib/src/material_localizations.dart`.'''); // We generate one class per supported language (e.g. // `MaterialLocalizationEn`). These implement everything that is needed by @@ -256,7 +256,7 @@ String generateTranslationBundles() { } } - // Generate the getTranslation function. Given a Locale it returns the + // Generate the getMaterialTranslation function. Given a Locale it returns the // corresponding const GlobalMaterialLocalizations. output.writeln(''' @@ -270,7 +270,7 @@ String generateTranslationBundles() { /// /// See also: /// -/// * [getTranslation], whose documentation describes these values. +/// * [getMaterialTranslation], whose documentation describes these values. final Set kSupportedLanguages = HashSet.from(const [ ${languageCodes.map((String value) => " '$value', // ${describeLocale(value)}").toList().join('\n')} ]); @@ -289,7 +289,7 @@ $supportedLocales/// {@endtemplate} /// /// Generally speaking, this method is only intended to be used by /// [GlobalMaterialLocalizations.delegate]. -GlobalMaterialLocalizations getTranslation( +GlobalMaterialLocalizations getMaterialTranslation( Locale locale, intl.DateFormat fullYearFormat, intl.DateFormat mediumDateFormat, @@ -404,7 +404,7 @@ GlobalMaterialLocalizations getTranslation( } output.writeln(''' } - assert(false, 'getTranslation() called for unsupported locale "\$locale"'); + assert(false, 'getMaterialTranslation() called for unsupported locale "\$locale"'); return null; }'''); @@ -603,7 +603,7 @@ Future main(List rawArgs) async { // code. In most cases both codes are just two characters. final Directory directory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); - final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); + final RegExp materialFilenameRE = RegExp(r'material_(\w+)\.arb$'); try { validateEnglishLocalizations(File(path.join(directory.path, 'material_en.arb'))); @@ -615,8 +615,8 @@ Future main(List rawArgs) async { for (FileSystemEntity entity in directory.listSync()) { final String entityPath = entity.path; - if (FileSystemEntity.isFileSync(entityPath) && filenameRE.hasMatch(entityPath)) { - processBundle(File(entityPath), localeString: filenameRE.firstMatch(entityPath)[1]); + if (FileSystemEntity.isFileSync(entityPath) && materialFilenameRE.hasMatch(entityPath)) { + processBundle(File(entityPath), localeString: materialFilenameRE.firstMatch(entityPath)[1]); } } @@ -627,12 +627,12 @@ Future main(List rawArgs) async { } final StringBuffer buffer = StringBuffer(); - buffer.writeln(outputHeader.replaceFirst('@(regenerate)', 'dart dev/tools/gen_localizations.dart --overwrite')); + buffer.writeln(outputHeader.replaceFirst('@(regenerate)', 'dart dev/tools/localization/gen_localizations.dart --overwrite')); buffer.write(generateTranslationBundles()); if (options.writeToFile) { - final File localizationsFile = File(path.join(directory.path, 'localizations.dart')); - localizationsFile.writeAsStringSync(buffer.toString()); + final File localizationsFile = File(path.join(directory.path, 'generated_material_localizations.dart')); + localizationsFile.writeAsStringSync(buffer.toString(), flush: true); } else { stdout.write(buffer.toString()); } diff --git a/dev/tools/localizations_utils.dart b/dev/tools/localization/localizations_utils.dart similarity index 100% rename from dev/tools/localizations_utils.dart rename to dev/tools/localization/localizations_utils.dart diff --git a/dev/tools/localizations_validator.dart b/dev/tools/localization/localizations_validator.dart similarity index 99% rename from dev/tools/localizations_validator.dart rename to dev/tools/localization/localizations_validator.dart index bbbb1dee43..9ab33d2052 100644 --- a/dev/tools/localizations_validator.dart +++ b/dev/tools/localization/localizations_validator.dart @@ -19,8 +19,7 @@ class ValidationError implements Exception { String toString() => message; } -/// Sanity checking of the @foo metadata in the English translations, -/// material_en.arb. +/// Sanity checking of the @foo metadata in the English translations, *_en.arb. /// /// - For each foo, resource, there must be a corresponding @foo. /// - For each @foo resource, there must be a corresponding foo, except diff --git a/packages/flutter/lib/src/material/material_localizations.dart b/packages/flutter/lib/src/material/material_localizations.dart index 2550de41ac..82aaf0080b 100644 --- a/packages/flutter/lib/src/material/material_localizations.dart +++ b/packages/flutter/lib/src/material/material_localizations.dart @@ -31,8 +31,8 @@ import 'typography.dart'; // you must add it to every other language (all the other *.arb files in that // same directory), listing the translation as `TBD`. After that you have to // re-generate lib/src/l10n/localizations.dart by running -// `dart dev/tools/gen_localizations.dart --overwrite`. There is a README -// file with further information in the lib/src/l10n/ directory. +// `dart dev/tools/localization/gen_localizations.dart --overwrite`. There is +// a README file with further information in the lib/src/l10n/ directory. // // 5. If you are a Google employee, you should then also follow the instructions // at go/flutter-l10n. If you're not, don't worry about it. diff --git a/packages/flutter_localizations/lib/flutter_localizations.dart b/packages/flutter_localizations/lib/flutter_localizations.dart index 83d910929c..354a9254f6 100644 --- a/packages/flutter_localizations/lib/flutter_localizations.dart +++ b/packages/flutter_localizations/lib/flutter_localizations.dart @@ -5,6 +5,6 @@ /// Localizations for the Flutter library library flutter_localizations; -export 'src/l10n/localizations.dart'; +export 'src/l10n/generated_material_localizations.dart'; export 'src/material_localizations.dart'; export 'src/widgets_localizations.dart'; diff --git a/packages/flutter_localizations/lib/src/l10n/README.md b/packages/flutter_localizations/lib/src/l10n/README.md index bcd4cdbab5..43fb482044 100644 --- a/packages/flutter_localizations/lib/src/l10n/README.md +++ b/packages/flutter_localizations/lib/src/l10n/README.md @@ -148,13 +148,13 @@ section in the Material spec. The Material theme uses the ### Generated file localizations.dart: all of the localizations as a Map If you look at the comment at the top of `localizations.dart` you'll -see that it was manually generated using a `dev/tools` app called +see that it was manually generated using a `dev/tools/localization` app called `gen_localizations`. You can see what that script would generate by running this command: ```dart -dart dev/tools/gen_localizations.dart packages/flutter_localizations/lib/src/l10n material +dart dev/tools/localization/gen_localizations.dart packages/flutter_localizations/lib/src/l10n material ``` The gen_localizations app just combines the contents of all of the @@ -172,7 +172,7 @@ To in-place update the `localizations.dart` file using the default values, you can just run: ```dart -dart dev/tools/gen_localizations.dart --overwrite +dart dev/tools/localization/gen_localizations.dart --overwrite ``` diff --git a/packages/flutter_localizations/lib/src/l10n/date_localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart similarity index 99% rename from packages/flutter_localizations/lib/src/l10n/date_localizations.dart rename to packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart index c2a0f5f7ac..3f11af3c69 100644 --- a/packages/flutter_localizations/lib/src/l10n/date_localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart @@ -4,7 +4,7 @@ // This file has been automatically generated. Please do not edit it manually. // To regenerate run (omit --overwrite to print to console instead of the file): -// dart --enable-asserts dev/tools/gen_date_localizations.dart --overwrite +// dart --enable-asserts dev/tools/localization/gen_date_localizations.dart --overwrite /// The subset of date symbols supported by the intl package which are also /// supported by flutter_localizations. diff --git a/packages/flutter_localizations/lib/src/l10n/localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart similarity index 99% rename from packages/flutter_localizations/lib/src/l10n/localizations.dart rename to packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart index 95e4aed84a..e09bee3dfb 100644 --- a/packages/flutter_localizations/lib/src/l10n/localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart @@ -4,7 +4,7 @@ // This file has been automatically generated. Please do not edit it manually. // To regenerate the file, use: -// dart dev/tools/gen_localizations.dart --overwrite +// dart dev/tools/localization/gen_localizations.dart --overwrite import 'dart:collection'; @@ -17,9 +17,9 @@ import '../material_localizations.dart'; // The classes defined here encode all of the translations found in the // `flutter_localizations/lib/src/l10n/*.arb` files. // -// These classes are constructed by the [getTranslation] method at the bottom of -// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined -// in `flutter_localizations/lib/src/material_localizations.dart`. +// These classes are constructed by the [getMaterialTranslation] method at the +// bottom of this file, and used by the [_MaterialLocalizationsDelegate.load] +// method defined in `flutter_localizations/lib/src/material_localizations.dart`. /// The translations for Arabic (`ar`). class MaterialLocalizationAr extends GlobalMaterialLocalizations { @@ -13144,7 +13144,7 @@ class MaterialLocalizationZhHantTw extends MaterialLocalizationZhHant { /// /// See also: /// -/// * [getTranslation], whose documentation describes these values. +/// * [getMaterialTranslation], whose documentation describes these values. final Set kSupportedLanguages = HashSet.from(const [ 'ar', // Arabic 'bg', // Bulgarian @@ -13266,7 +13266,7 @@ final Set kSupportedLanguages = HashSet.from(const [ /// /// Generally speaking, this method is only intended to be used by /// [GlobalMaterialLocalizations.delegate]. -GlobalMaterialLocalizations getTranslation( +GlobalMaterialLocalizations getMaterialTranslation( Locale locale, intl.DateFormat fullYearFormat, intl.DateFormat mediumDateFormat, @@ -13486,6 +13486,6 @@ GlobalMaterialLocalizations getTranslation( return MaterialLocalizationZh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } } - assert(false, 'getTranslation() called for unsupported locale "$locale"'); + assert(false, 'getMaterialTranslation() called for unsupported locale "$locale"'); return null; } diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 93181f245b..363240623c 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart' as intl; import 'package:intl/date_symbols.dart' as intl; import 'package:intl/date_symbol_data_custom.dart' as date_symbol_data_custom; -import 'l10n/date_localizations.dart' as date_localizations; +import 'l10n/generated_date_localizations.dart' as date_localizations; -import 'l10n/localizations.dart'; +import 'l10n/generated_material_localizations.dart'; import 'widgets_localizations.dart'; /// Implementation of localized strings for the material widgets using the @@ -647,7 +647,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate(getTranslation( + return SynchronousFuture(getMaterialTranslation( locale, fullYearFormat, mediumDateFormat,