update generated localized message files in the stocks test app (#148741)
Fixes https://github.com/flutter/flutter/issues/149386. Fixes https://github.com/flutter/flutter/issues/106150. The stocks test app includes Dart files containing localized messages generated by `package:flutter_localizations`. However, these files appear to have become out of date. Running `pub get` in the project will regenerate these files and generate a diff, which can be annoying when working on the repo. This PR generates the files. ~~It also updates the templates for these files to be compliant with flutter/flutter repo lint rules, including `noop_primitive_operations` and `use_super_parameters`.~~ It also adds `// ignore_for_file: type=lint` to these files to disable linting for these files. This avoids issues like https://github.com/flutter/flutter/issues/106150 and [this](https://github.com/flutter/flutter/pull/148741#issuecomment-2141161753).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Regenerating the i18n files
|
||||
|
||||
The files in this directory are used to generate `stock_strings.dart`,
|
||||
The arb files in this directory are used to generate `stock_strings.dart`,
|
||||
which contains the `StockStrings` class. This localizations class is
|
||||
used by the stocks application to look up localized message strings.
|
||||
The stocks app uses the [Dart `intl` package](https://github.com/dart-lang/intl).
|
||||
|
||||
@@ -14,12 +14,14 @@ import 'package:intl/intl.dart' as intl;
|
||||
import 'stock_strings_en.dart';
|
||||
import 'stock_strings_es.dart';
|
||||
|
||||
/// Callers can lookup localized strings with an instance of StockStrings returned
|
||||
/// by `StockStrings.of(context)`.
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// Callers can lookup localized strings with an instance of StockStrings
|
||||
/// returned by `StockStrings.of(context)`.
|
||||
///
|
||||
/// Applications need to include `StockStrings.delegate()` in their app's
|
||||
/// localizationDelegates list, and the locales they support in the app's
|
||||
/// supportedLocales list. For example:
|
||||
/// `localizationDelegates` list, and the locales they support in the app's
|
||||
/// `supportedLocales` list. For example:
|
||||
///
|
||||
/// ```dart
|
||||
/// import 'i18n/stock_strings.dart';
|
||||
@@ -43,7 +45,7 @@ import 'stock_strings_es.dart';
|
||||
/// sdk: flutter
|
||||
/// intl: any # Use the pinned version from flutter_localizations
|
||||
///
|
||||
/// # rest of dependencies
|
||||
/// # Rest of dependencies
|
||||
/// ```
|
||||
///
|
||||
/// ## iOS Applications
|
||||
@@ -66,7 +68,7 @@ import 'stock_strings_es.dart';
|
||||
/// be consistent with the languages listed in the StockStrings.supportedLocales
|
||||
/// property.
|
||||
abstract class StockStrings {
|
||||
StockStrings(String locale) : localeName = intl.Intl.canonicalizedLocale(locale);
|
||||
StockStrings(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
|
||||
final String localeName;
|
||||
|
||||
@@ -97,7 +99,7 @@ abstract class StockStrings {
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('en', 'US'),
|
||||
Locale('es'),
|
||||
Locale('es')
|
||||
];
|
||||
|
||||
/// Title for the Stocks application
|
||||
@@ -124,7 +126,7 @@ class _StockStringsDelegate extends LocalizationsDelegate<StockStrings> {
|
||||
|
||||
@override
|
||||
Future<StockStrings> load(Locale locale) {
|
||||
return SynchronousFuture<StockStrings>(_lookupStockStrings(locale));
|
||||
return SynchronousFuture<StockStrings>(lookupStockStrings(locale));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -134,16 +136,16 @@ class _StockStringsDelegate extends LocalizationsDelegate<StockStrings> {
|
||||
bool shouldReload(_StockStringsDelegate old) => false;
|
||||
}
|
||||
|
||||
StockStrings _lookupStockStrings(Locale locale) {
|
||||
StockStrings lookupStockStrings(Locale locale) {
|
||||
|
||||
// Lookup logic when language+country codes are specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en': {
|
||||
switch (locale.countryCode) {
|
||||
case 'US': return StockStringsEnUs();
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (locale.countryCode) {
|
||||
case 'US': return StockStringsEnUs();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Lookup logic when only language code is specified.
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
// THE FOLLOWING FILES WERE GENERATED BY `flutter gen-l10n`.
|
||||
|
||||
|
||||
|
||||
import 'stock_strings.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class StockStringsEn extends StockStrings {
|
||||
StockStringsEn([super.locale = 'en']);
|
||||
StockStringsEn([String locale = 'en']) : super(locale);
|
||||
|
||||
@override
|
||||
String get title => 'Stocks';
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
// THE FOLLOWING FILES WERE GENERATED BY `flutter gen-l10n`.
|
||||
|
||||
|
||||
|
||||
import 'stock_strings.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for Spanish Castilian (`es`).
|
||||
class StockStringsEs extends StockStrings {
|
||||
StockStringsEs([super.locale = 'es']);
|
||||
StockStringsEs([String locale = 'es']) : super(locale);
|
||||
|
||||
@override
|
||||
String get title => 'Acciones';
|
||||
|
||||
@@ -18,6 +18,8 @@ import 'package:intl/intl.dart' as intl;
|
||||
|
||||
@(messageClassImports)
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// Callers can lookup localized strings with an instance of @(class)
|
||||
/// returned by `@(class).of(context)`.
|
||||
///
|
||||
@@ -171,6 +173,8 @@ const String dateVariableTemplate = '''
|
||||
const String classFileTemplate = '''
|
||||
@(header)@(requiresIntlImport)import '@(fileName)';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for @(language) (`@(localeName)`).
|
||||
class @(class) extends @(baseClass) {
|
||||
@(class)([String locale = '@(localeName)']) : super(locale);
|
||||
|
||||
@@ -794,6 +794,8 @@ HEADER
|
||||
|
||||
import 'bar.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class FooEn extends Foo {
|
||||
FooEn([String locale = 'en']) : super(locale);
|
||||
@@ -894,6 +896,8 @@ flutter:\r
|
||||
expect(fs.file('/lib/l10n/app_localizations_en.dart').readAsStringSync(), '''
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class AppLocalizationsEn extends AppLocalizations {
|
||||
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||
@@ -925,6 +929,8 @@ HEADER
|
||||
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class AppLocalizationsEn extends AppLocalizations {
|
||||
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||
|
||||
Reference in New Issue
Block a user