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 {
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
......
......@@ -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.
......
......@@ -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';
......@@ -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
```
......
......@@ -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.
......
......@@ -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<String> kSupportedLanguages = HashSet<String>.from(const <String>[
'ar', // Arabic
'bg', // Bulgarian
......@@ -13266,7 +13266,7 @@ final Set<String> kSupportedLanguages = HashSet<String>.from(const <String>[
///
/// 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;
}
......@@ -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<MaterialLocal
assert(locale.toString() == localeName, 'comparing "$locale" to "$localeName"');
return SynchronousFuture<MaterialLocalizations>(getTranslation(
return SynchronousFuture<MaterialLocalizations>(getMaterialTranslation(
locale,
fullYearFormat,
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