Cupertino localization step 3: in-place move some material tools around to make room for cupertino (#29644)
This commit is contained in:
@@ -94,12 +94,12 @@ Future<void> _verifyInternationalizations() async {
|
||||
final EvalResult genResult = await _evalCommand(
|
||||
dart,
|
||||
<String>[
|
||||
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()) {
|
||||
|
||||
@@ -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<void> main(List<String> 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<void> main(List<String> 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'), <String>[
|
||||
'-w',
|
||||
@@ -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<String> kSupportedLanguages = HashSet<String>.from(const <String>[
|
||||
${languageCodes.map<String>((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<void> main(List<String> 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<void> main(List<String> 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<void> main(List<String> 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());
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user