diff --git a/packages/neon/neon_dashboard/l10n.yaml b/packages/neon/neon_dashboard/l10n.yaml index 7974745e..b9ab5efe 100644 --- a/packages/neon/neon_dashboard/l10n.yaml +++ b/packages/neon/neon_dashboard/l10n.yaml @@ -2,5 +2,6 @@ arb-dir: lib/l10n template-arb-file: en.arb output-localization-file: localizations.dart synthetic-package: false +output-class: DashboardLocalizations output-dir: lib/l10n nullable-getter: false diff --git a/packages/neon/neon_dashboard/lib/l10n/localizations.dart b/packages/neon/neon_dashboard/lib/l10n/localizations.dart index 0a2e2f7e..796e67c9 100644 --- a/packages/neon/neon_dashboard/lib/l10n/localizations.dart +++ b/packages/neon/neon_dashboard/lib/l10n/localizations.dart @@ -7,10 +7,10 @@ import 'package:intl/intl.dart' as intl; import 'localizations_en.dart'; -/// Callers can lookup localized strings with an instance of AppLocalizations -/// returned by `AppLocalizations.of(context)`. +/// Callers can lookup localized strings with an instance of DashboardLocalizations +/// returned by `DashboardLocalizations.of(context)`. /// -/// Applications need to include `AppLocalizations.delegate()` in their app's +/// Applications need to include `DashboardLocalizations.delegate()` in their app's /// `localizationDelegates` list, and the locales they support in the app's /// `supportedLocales` list. For example: /// @@ -18,8 +18,8 @@ import 'localizations_en.dart'; /// import 'l10n/localizations.dart'; /// /// return MaterialApp( -/// localizationsDelegates: AppLocalizations.localizationsDelegates, -/// supportedLocales: AppLocalizations.supportedLocales, +/// localizationsDelegates: DashboardLocalizations.localizationsDelegates, +/// supportedLocales: DashboardLocalizations.supportedLocales, /// home: MyApplicationHome(), /// ); /// ``` @@ -56,18 +56,18 @@ import 'localizations_en.dart'; /// Select and expand the newly-created Localizations item then, for each /// locale your application supports, add a new item and select the locale /// you wish to add from the pop-up menu in the Value field. This list should -/// be consistent with the languages listed in the AppLocalizations.supportedLocales +/// be consistent with the languages listed in the DashboardLocalizations.supportedLocales /// property. -abstract class AppLocalizations { - AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString()); +abstract class DashboardLocalizations { + DashboardLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString()); final String localeName; - static AppLocalizations of(BuildContext context) { - return Localizations.of(context, AppLocalizations)!; + static DashboardLocalizations of(BuildContext context) { + return Localizations.of(context, DashboardLocalizations)!; } - static const LocalizationsDelegate delegate = _AppLocalizationsDelegate(); + static const LocalizationsDelegate delegate = _DashboardLocalizationsDelegate(); /// A list of this localizations delegate along with the default localizations /// delegates. @@ -96,29 +96,29 @@ abstract class AppLocalizations { String get noEntries; } -class _AppLocalizationsDelegate extends LocalizationsDelegate { - const _AppLocalizationsDelegate(); +class _DashboardLocalizationsDelegate extends LocalizationsDelegate { + const _DashboardLocalizationsDelegate(); @override - Future load(Locale locale) { - return SynchronousFuture(lookupAppLocalizations(locale)); + Future load(Locale locale) { + return SynchronousFuture(lookupDashboardLocalizations(locale)); } @override bool isSupported(Locale locale) => ['en'].contains(locale.languageCode); @override - bool shouldReload(_AppLocalizationsDelegate old) => false; + bool shouldReload(_DashboardLocalizationsDelegate old) => false; } -AppLocalizations lookupAppLocalizations(Locale locale) { +DashboardLocalizations lookupDashboardLocalizations(Locale locale) { // Lookup logic when only language code is specified. switch (locale.languageCode) { case 'en': - return AppLocalizationsEn(); + return DashboardLocalizationsEn(); } - throw FlutterError('AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' + throw FlutterError('DashboardLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' 'an issue with the localizations generation tool. Please file an issue ' 'on GitHub with a reproducible sample app and the gen-l10n configuration ' 'that was used.'); diff --git a/packages/neon/neon_dashboard/lib/l10n/localizations_en.dart b/packages/neon/neon_dashboard/lib/l10n/localizations_en.dart index d4a69229..d8bfcc02 100644 --- a/packages/neon/neon_dashboard/lib/l10n/localizations_en.dart +++ b/packages/neon/neon_dashboard/lib/l10n/localizations_en.dart @@ -1,8 +1,8 @@ import 'localizations.dart'; /// The translations for English (`en`). -class AppLocalizationsEn extends AppLocalizations { - AppLocalizationsEn([String locale = 'en']) : super(locale); +class DashboardLocalizationsEn extends DashboardLocalizations { + DashboardLocalizationsEn([String locale = 'en']) : super(locale); @override String get noEntries => 'No entries'; diff --git a/packages/neon/neon_dashboard/lib/src/app.dart b/packages/neon/neon_dashboard/lib/src/app.dart index b1958f67..69c4c1f6 100644 --- a/packages/neon/neon_dashboard/lib/src/app.dart +++ b/packages/neon/neon_dashboard/lib/src/app.dart @@ -18,10 +18,10 @@ class DashboardApp extends AppImplementation localizationsDelegate = AppLocalizations.delegate; + final LocalizationsDelegate localizationsDelegate = DashboardLocalizations.delegate; @override - final List supportedLocales = AppLocalizations.supportedLocales; + final List supportedLocales = DashboardLocalizations.supportedLocales; @override late final DashboardAppSpecificOptions options = DashboardAppSpecificOptions(storage); diff --git a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart index 4c3844bc..d2559c62 100644 --- a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart +++ b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart @@ -60,7 +60,7 @@ class DashboardWidget extends StatelessWidget { if (halfEmptyContentMessage != null) halfEmptyContentMessage, if (emptyContentMessage != null) emptyContentMessage, if (halfEmptyContentMessage == null && emptyContentMessage == null && (items?.items.isEmpty ?? true)) - _renderMessage(AppLocalizations.of(context).noEntries)!, + _renderMessage(DashboardLocalizations.of(context).noEntries)!, ...?items?.items.map( (final item) => DashboardWidgetItem( item: item, diff --git a/packages/neon/neon_dashboard/test/widget_test.dart b/packages/neon/neon_dashboard/test/widget_test.dart index 6ec81bca..c05d5ddb 100644 --- a/packages/neon/neon_dashboard/test/widget_test.dart +++ b/packages/neon/neon_dashboard/test/widget_test.dart @@ -17,8 +17,8 @@ import 'package:rxdart/rxdart.dart'; class MockAccountsBloc extends Mock implements AccountsBloc {} Widget wrapWidget(final AccountsBloc accountsBloc, final Widget child) => MaterialApp( - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: DashboardLocalizations.localizationsDelegates, + supportedLocales: DashboardLocalizations.supportedLocales, home: Scaffold( backgroundColor: Colors.transparent, body: NeonProvider.value(