Update gen_l10n tool to require base locale; Stocks app refresh (#51602)
This commit is contained in:
@@ -8,6 +8,7 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps
|
||||
@@ -67,6 +68,7 @@ import 'package:intl/intl.dart' as intl;
|
||||
abstract class @(class) {
|
||||
@(class)(String locale) : assert(locale != null), _localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
|
||||
// ignore: unused_field
|
||||
final String _localeName;
|
||||
|
||||
static @(class) of(BuildContext context) {
|
||||
|
||||
@@ -423,6 +423,23 @@ class AppResourceBundleCollection {
|
||||
languageToLocales[bundle.locale.languageCode].add(bundle.locale);
|
||||
}
|
||||
}
|
||||
|
||||
languageToLocales.forEach((String language, List<LocaleInfo> listOfCorrespondingLocales) {
|
||||
final List<String> localeStrings = listOfCorrespondingLocales.map((LocaleInfo locale) {
|
||||
return locale.toString();
|
||||
}).toList();
|
||||
if (!localeStrings.contains(language)) {
|
||||
throw L10nException(
|
||||
'Arb file for a fallback, $language, does not exist, even though \n'
|
||||
'the following locale(s) exist: $listOfCorrespondingLocales. \n'
|
||||
'When locales specify a script code or country code, a \n'
|
||||
'base locale (without the script code or country code) should \n'
|
||||
'exist as the fallback. Please create a {fileName}_$language.arb \n'
|
||||
'file.'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return AppResourceBundleCollection._(directory, localeToBundle, languageToLocales);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user