Unverified Commit f2d671c1 authored by xster's avatar xster Committed by GitHub

Cupertino localization step 3: in-place move some material tools around to...

Cupertino localization step 3: in-place move some material tools around to make room for cupertino (#29644)
parent d166a8d8
...@@ -94,12 +94,12 @@ Future<void> _verifyInternationalizations() async { ...@@ -94,12 +94,12 @@ Future<void> _verifyInternationalizations() async {
final EvalResult genResult = await _evalCommand( final EvalResult genResult = await _evalCommand(
dart, dart,
<String>[ <String>[
path.join('dev', 'tools', 'gen_localizations.dart'), path.join('dev', 'tools', 'localization', 'gen_localizations.dart'),
], ],
workingDirectory: flutterRoot, 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(); final String expectedResult = await File(localizationsFile).readAsString();
if (genResult.stdout.trim() != expectedResult.trim()) { if (genResult.stdout.trim() != expectedResult.trim()) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
/// package. /// package.
/// ///
/// The extracted data is written into: /// 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 /// ## Usage
/// ///
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
/// The following outputs the generated Dart code to the console as a dry run: /// 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 /// If the data looks good, use the `--overwrite` option to overwrite the
/// lib/src/l10n/date_localizations.dart file: /// 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'; import 'dart:async';
...@@ -79,7 +79,7 @@ Future<void> main(List<String> rawArgs) async { ...@@ -79,7 +79,7 @@ Future<void> main(List<String> rawArgs) async {
// This file has been automatically generated. Please do not edit it manually. // 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): // 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<void> main(List<String> rawArgs) async { ...@@ -113,7 +113,7 @@ Future<void> main(List<String> rawArgs) async {
buffer.writeln('};'); buffer.writeln('};');
if (writeToFile) { 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()); dateLocalizationsFile.writeAsStringSync(buffer.toString());
Process.runSync(path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartfmt'), <String>[ Process.runSync(path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartfmt'), <String>[
'-w', '-w',
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This program generates a getTranslation() function that looks up the // This program generates a getMaterialTranslation() function that looks up the
// translations contained by the arb files. The returned value is an // translations provided by the arb files. The returned value is a generated
// instance of GlobalMaterialLocalizations that corresponds to a single // instance of GlobalMaterialLocalizations that corresponds to a single
// locale. // locale.
// //
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
// The following outputs the generated Dart code to the console as a dry run: // 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 // 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'; import 'dart:async';
...@@ -144,9 +144,9 @@ String generateTranslationBundles() { ...@@ -144,9 +144,9 @@ String generateTranslationBundles() {
// The classes defined here encode all of the translations found in the // The classes defined here encode all of the translations found in the
// `flutter_localizations/lib/src/l10n/*.arb` files. // `flutter_localizations/lib/src/l10n/*.arb` files.
// //
// These classes are constructed by the [getTranslation] method at the bottom of // These classes are constructed by the [getMaterialTranslation] method at the
// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined // bottom of this file, and used by the [_MaterialLocalizationsDelegate.load]
// in `flutter_localizations/lib/src/material_localizations.dart`.'''); // method defined in `flutter_localizations/lib/src/material_localizations.dart`.''');
// We generate one class per supported language (e.g. // We generate one class per supported language (e.g.
// `MaterialLocalizationEn`). These implement everything that is needed by // `MaterialLocalizationEn`). These implement everything that is needed by
...@@ -256,7 +256,7 @@ String generateTranslationBundles() { ...@@ -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. // corresponding const GlobalMaterialLocalizations.
output.writeln(''' output.writeln('''
...@@ -270,7 +270,7 @@ String generateTranslationBundles() { ...@@ -270,7 +270,7 @@ String generateTranslationBundles() {
/// ///
/// See also: /// See also:
/// ///
/// * [getTranslation], whose documentation describes these values. /// * [getMaterialTranslation], whose documentation describes these values.
final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[ final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[
${languageCodes.map<String>((String value) => " '$value', // ${describeLocale(value)}").toList().join('\n')} ${languageCodes.map<String>((String value) => " '$value', // ${describeLocale(value)}").toList().join('\n')}
]); ]);
...@@ -289,7 +289,7 @@ $supportedLocales/// {@endtemplate} ...@@ -289,7 +289,7 @@ $supportedLocales/// {@endtemplate}
/// ///
/// Generally speaking, this method is only intended to be used by /// Generally speaking, this method is only intended to be used by
/// [GlobalMaterialLocalizations.delegate]. /// [GlobalMaterialLocalizations.delegate].
GlobalMaterialLocalizations getTranslation( GlobalMaterialLocalizations getMaterialTranslation(
Locale locale, Locale locale,
intl.DateFormat fullYearFormat, intl.DateFormat fullYearFormat,
intl.DateFormat mediumDateFormat, intl.DateFormat mediumDateFormat,
...@@ -404,7 +404,7 @@ GlobalMaterialLocalizations getTranslation( ...@@ -404,7 +404,7 @@ GlobalMaterialLocalizations getTranslation(
} }
output.writeln(''' output.writeln('''
} }
assert(false, 'getTranslation() called for unsupported locale "\$locale"'); assert(false, 'getMaterialTranslation() called for unsupported locale "\$locale"');
return null; return null;
}'''); }''');
...@@ -603,7 +603,7 @@ Future<void> main(List<String> rawArgs) async { ...@@ -603,7 +603,7 @@ Future<void> main(List<String> rawArgs) async {
// code. In most cases both codes are just two characters. // code. In most cases both codes are just two characters.
final Directory directory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); 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 { try {
validateEnglishLocalizations(File(path.join(directory.path, 'material_en.arb'))); validateEnglishLocalizations(File(path.join(directory.path, 'material_en.arb')));
...@@ -615,8 +615,8 @@ Future<void> main(List<String> rawArgs) async { ...@@ -615,8 +615,8 @@ Future<void> main(List<String> rawArgs) async {
for (FileSystemEntity entity in directory.listSync()) { for (FileSystemEntity entity in directory.listSync()) {
final String entityPath = entity.path; final String entityPath = entity.path;
if (FileSystemEntity.isFileSync(entityPath) && filenameRE.hasMatch(entityPath)) { if (FileSystemEntity.isFileSync(entityPath) && materialFilenameRE.hasMatch(entityPath)) {
processBundle(File(entityPath), localeString: filenameRE.firstMatch(entityPath)[1]); processBundle(File(entityPath), localeString: materialFilenameRE.firstMatch(entityPath)[1]);
} }
} }
...@@ -627,12 +627,12 @@ Future<void> main(List<String> rawArgs) async { ...@@ -627,12 +627,12 @@ Future<void> main(List<String> rawArgs) async {
} }
final StringBuffer buffer = StringBuffer(); 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()); buffer.write(generateTranslationBundles());
if (options.writeToFile) { if (options.writeToFile) {
final File localizationsFile = File(path.join(directory.path, 'localizations.dart')); final File localizationsFile = File(path.join(directory.path, 'generated_material_localizations.dart'));
localizationsFile.writeAsStringSync(buffer.toString()); localizationsFile.writeAsStringSync(buffer.toString(), flush: true);
} else { } else {
stdout.write(buffer.toString()); stdout.write(buffer.toString());
} }
......
...@@ -19,8 +19,7 @@ class ValidationError implements Exception { ...@@ -19,8 +19,7 @@ class ValidationError implements Exception {
String toString() => message; String toString() => message;
} }
/// Sanity checking of the @foo metadata in the English translations, /// Sanity checking of the @foo metadata in the English translations, *_en.arb.
/// material_en.arb.
/// ///
/// - For each foo, resource, there must be a corresponding @foo. /// - For each foo, resource, there must be a corresponding @foo.
/// - For each @foo resource, there must be a corresponding foo, except /// - For each @foo resource, there must be a corresponding foo, except
......
...@@ -31,8 +31,8 @@ import 'typography.dart'; ...@@ -31,8 +31,8 @@ import 'typography.dart';
// you must add it to every other language (all the other *.arb files in that // 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 // same directory), listing the translation as `TBD`. After that you have to
// re-generate lib/src/l10n/localizations.dart by running // re-generate lib/src/l10n/localizations.dart by running
// `dart dev/tools/gen_localizations.dart --overwrite`. There is a README // `dart dev/tools/localization/gen_localizations.dart --overwrite`. There is
// file with further information in the lib/src/l10n/ directory. // 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 // 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. // at go/flutter-l10n. If you're not, don't worry about it.
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
/// Localizations for the Flutter library /// Localizations for the Flutter library
library flutter_localizations; library flutter_localizations;
export 'src/l10n/localizations.dart'; export 'src/l10n/generated_material_localizations.dart';
export 'src/material_localizations.dart'; export 'src/material_localizations.dart';
export 'src/widgets_localizations.dart'; export 'src/widgets_localizations.dart';
...@@ -148,13 +148,13 @@ section in the Material spec. The Material theme uses the ...@@ -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 ### 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 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`. `gen_localizations`.
You can see what that script would generate by running this command: You can see what that script would generate by running this command:
```dart ```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 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 ...@@ -172,7 +172,7 @@ To in-place update the `localizations.dart` file using the default
values, you can just run: values, you can just run:
```dart ```dart
dart dev/tools/gen_localizations.dart --overwrite dart dev/tools/localization/gen_localizations.dart --overwrite
``` ```
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// This file has been automatically generated. Please do not edit it manually. // 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): // 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 /// The subset of date symbols supported by the intl package which are also
/// supported by flutter_localizations. /// supported by flutter_localizations.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// This file has been automatically generated. Please do not edit it manually. // This file has been automatically generated. Please do not edit it manually.
// To regenerate the file, use: // To regenerate the file, use:
// dart dev/tools/gen_localizations.dart --overwrite // dart dev/tools/localization/gen_localizations.dart --overwrite
import 'dart:collection'; import 'dart:collection';
...@@ -17,9 +17,9 @@ import '../material_localizations.dart'; ...@@ -17,9 +17,9 @@ import '../material_localizations.dart';
// The classes defined here encode all of the translations found in the // The classes defined here encode all of the translations found in the
// `flutter_localizations/lib/src/l10n/*.arb` files. // `flutter_localizations/lib/src/l10n/*.arb` files.
// //
// These classes are constructed by the [getTranslation] method at the bottom of // These classes are constructed by the [getMaterialTranslation] method at the
// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined // bottom of this file, and used by the [_MaterialLocalizationsDelegate.load]
// in `flutter_localizations/lib/src/material_localizations.dart`. // method defined in `flutter_localizations/lib/src/material_localizations.dart`.
/// The translations for Arabic (`ar`). /// The translations for Arabic (`ar`).
class MaterialLocalizationAr extends GlobalMaterialLocalizations { class MaterialLocalizationAr extends GlobalMaterialLocalizations {
...@@ -13144,7 +13144,7 @@ class MaterialLocalizationZhHantTw extends MaterialLocalizationZhHant { ...@@ -13144,7 +13144,7 @@ class MaterialLocalizationZhHantTw extends MaterialLocalizationZhHant {
/// ///
/// See also: /// See also:
/// ///
/// * [getTranslation], whose documentation describes these values. /// * [getMaterialTranslation], whose documentation describes these values.
final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[ final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[
'ar', // Arabic 'ar', // Arabic
'bg', // Bulgarian 'bg', // Bulgarian
...@@ -13266,7 +13266,7 @@ final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[ ...@@ -13266,7 +13266,7 @@ final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[
/// ///
/// Generally speaking, this method is only intended to be used by /// Generally speaking, this method is only intended to be used by
/// [GlobalMaterialLocalizations.delegate]. /// [GlobalMaterialLocalizations.delegate].
GlobalMaterialLocalizations getTranslation( GlobalMaterialLocalizations getMaterialTranslation(
Locale locale, Locale locale,
intl.DateFormat fullYearFormat, intl.DateFormat fullYearFormat,
intl.DateFormat mediumDateFormat, intl.DateFormat mediumDateFormat,
...@@ -13486,6 +13486,6 @@ GlobalMaterialLocalizations getTranslation( ...@@ -13486,6 +13486,6 @@ GlobalMaterialLocalizations getTranslation(
return MaterialLocalizationZh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); 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; return null;
} }
...@@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; ...@@ -9,9 +9,9 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart' as intl; import 'package:intl/intl.dart' as intl;
import 'package:intl/date_symbols.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 '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'; import 'widgets_localizations.dart';
/// Implementation of localized strings for the material widgets using the /// Implementation of localized strings for the material widgets using the
...@@ -647,7 +647,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal ...@@ -647,7 +647,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
assert(locale.toString() == localeName, 'comparing "$locale" to "$localeName"'); assert(locale.toString() == localeName, 'comparing "$locale" to "$localeName"');
return SynchronousFuture<MaterialLocalizations>(getTranslation( return SynchronousFuture<MaterialLocalizations>(getMaterialTranslation(
locale, locale,
fullYearFormat, fullYearFormat,
mediumDateFormat, mediumDateFormat,
......
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