diff --git a/l10n.yaml b/l10n.yaml index b522046b..ca3d94af 100644 --- a/l10n.yaml +++ b/l10n.yaml @@ -1,3 +1,4 @@ arb-dir: lib/l10n template-arb-file: intl_en.arb -output-localization-file: app_localizations.dart \ No newline at end of file +output-localization-file: l10n.dart +output-class: L10n diff --git a/lib/authentication/authentication_widget.dart b/lib/authentication/authentication_widget.dart index 572a9cdb..27c22b1d 100644 --- a/lib/authentication/authentication_widget.dart +++ b/lib/authentication/authentication_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'authentication_model.dart'; @@ -35,9 +35,7 @@ class AuthenticationWidget extends StatelessWidget { image: AssetImage('assets/images/img_google.png')), const SizedBox(width: 8), - Text( - AppLocalizations.of(context)! - .txt_button_sign_in_google, + Text(L10n.of(context)!.txt_button_sign_in_google, style: Theme.of(context).textTheme.subtitle1) ], ), @@ -60,9 +58,7 @@ class AuthenticationWidget extends StatelessWidget { image: AssetImage('assets/images/img_facebook.png')), const SizedBox(width: 8), - Text( - AppLocalizations.of(context)! - .txt_button_sign_in_facebook, + Text(L10n.of(context)!.txt_button_sign_in_facebook, style: Theme.of(context).textTheme.subtitle1) ], ), diff --git a/lib/game/complete_widget.dart b/lib/game/complete_widget.dart index cffe508c..76be4cbc 100644 --- a/lib/game/complete_widget.dart +++ b/lib/game/complete_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'game_reward.dart'; @@ -65,7 +65,7 @@ class CompleteWidget extends StatelessWidget { Navigator.of(context).pop(); Navigator.of(context).pop(); }, - child: Text(AppLocalizations.of(context)!.txt_button_quit), + child: Text(L10n.of(context)!.txt_button_quit), ), ), const SizedBox(width: 8), @@ -74,8 +74,7 @@ class CompleteWidget extends StatelessWidget { onPressed: () { _onRestart(); }, - child: Text( - AppLocalizations.of(context)!.txt_button_restart)), + child: Text(L10n.of(context)!.txt_button_restart)), ), const SizedBox(width: 8) ], diff --git a/lib/game/game_page.dart b/lib/game/game_page.dart index 76579a48..1743a3ae 100644 --- a/lib/game/game_page.dart +++ b/lib/game/game_page.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flame/game.dart' as flame; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../midi/midi_model.dart'; @@ -167,11 +167,11 @@ class GuideTextWidget extends ConsumerWidget { final guideText = watch(guideTextProvider).state; var text = ''; if (guideText == 'txt_too_late') { - text = AppLocalizations.of(context)!.txt_too_late; + text = L10n.of(context)!.txt_too_late; } else if (guideText == 'txt_too_early') { - text = AppLocalizations.of(context)!.txt_too_early; + text = L10n.of(context)!.txt_too_early; } else if (guideText == 'txt_too_many_fingers') { - text = AppLocalizations.of(context)!.txt_too_many_fingers; + text = L10n.of(context)!.txt_too_many_fingers; } return Text('$text', style: Theme.of(context) @@ -203,8 +203,7 @@ class LoadingSoundWidget extends StatelessWidget { image: AssetImage('assets/images/img_app_icon.png')), ), ), - Text(AppLocalizations.of(context)! - .txt_dialog_loading_sound_description) + Text(L10n.of(context)!.txt_dialog_loading_sound_description) ], )), ), @@ -234,8 +233,7 @@ class LoadingGiftWidget extends StatelessWidget { image: AssetImage('assets/images/img_app_icon.png')), ), ), - Text(AppLocalizations.of(context)! - .txt_game_complete_loading_gift) + Text(L10n.of(context)!.txt_game_complete_loading_gift) ], )), ), diff --git a/lib/game/pause_dialog.dart b/lib/game/pause_dialog.dart index 4bf111a3..f42d193d 100644 --- a/lib/game/pause_dialog.dart +++ b/lib/game/pause_dialog.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; class PauseDialog extends StatelessWidget { final Function() _onRestart; @@ -21,21 +21,20 @@ class PauseDialog extends StatelessWidget { Navigator.of(context).pop(); Navigator.of(context).pop(); }, - child: Text(AppLocalizations.of(context)!.txt_button_quit), + child: Text(L10n.of(context)!.txt_button_quit), ), ElevatedButton( onPressed: () { _onRestart(); Navigator.of(context).pop(); }, - child: Text(AppLocalizations.of(context)!.txt_button_restart), + child: Text(L10n.of(context)!.txt_button_restart), ), ElevatedButton( onPressed: () { Navigator.of(context).pop(); }, - child: - Text(AppLocalizations.of(context)!.txt_game_button_continue), + child: Text(L10n.of(context)!.txt_game_button_continue), ) ], ), diff --git a/lib/game_config/game_config_page.dart b/lib/game_config/game_config_page.dart index 099c2138..737fc968 100644 --- a/lib/game_config/game_config_page.dart +++ b/lib/game_config/game_config_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:sprintf/sprintf.dart'; @@ -20,7 +20,7 @@ class GameConfigPage extends ConsumerWidget { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.txt_configure, + title: Text(L10n.of(context)!.txt_configure, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: SafeArea( child: Column( @@ -32,7 +32,7 @@ class GameConfigPage extends ConsumerWidget { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(AppLocalizations.of(context)!.txt_difficulty, + Text(L10n.of(context)!.txt_difficulty, style: Theme.of(context).textTheme.headline5), const SizedBox(height: 8), Row( @@ -40,9 +40,8 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.difficulty == 0, - text: AppLocalizations.of(context)!.txt_easy, - caption: sprintf( - AppLocalizations.of(context)!.txt_fingers, [2]), + text: L10n.of(context)!.txt_easy, + caption: sprintf(L10n.of(context)!.txt_fingers, [2]), onTap: () { context .read(gameConfigStateProvider.notifier) @@ -52,9 +51,8 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.difficulty == 1, - text: AppLocalizations.of(context)!.txt_medium, - caption: sprintf( - AppLocalizations.of(context)!.txt_fingers, [3]), + text: L10n.of(context)!.txt_medium, + caption: sprintf(L10n.of(context)!.txt_fingers, [3]), onTap: () { context .read(gameConfigStateProvider.notifier) @@ -64,9 +62,8 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.difficulty == 2, - text: AppLocalizations.of(context)!.txt_difficult, - caption: sprintf( - AppLocalizations.of(context)!.txt_fingers, [4]), + text: L10n.of(context)!.txt_difficult, + caption: sprintf(L10n.of(context)!.txt_fingers, [4]), onTap: () { context .read(gameConfigStateProvider.notifier) @@ -84,7 +81,7 @@ class GameConfigPage extends ConsumerWidget { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(AppLocalizations.of(context)!.txt_speed, + Text(L10n.of(context)!.txt_speed, style: Theme.of(context).textTheme.headline5), const SizedBox(height: 8), Row( @@ -92,7 +89,7 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.speed == 0, - text: AppLocalizations.of(context)!.txt_slow, + text: L10n.of(context)!.txt_slow, caption: 'x0.75', onTap: () { context @@ -103,7 +100,7 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.speed == 1, - text: AppLocalizations.of(context)!.txt_normal, + text: L10n.of(context)!.txt_normal, caption: 'x1.0', onTap: () { context @@ -114,7 +111,7 @@ class GameConfigPage extends ConsumerWidget { const SizedBox(width: 8), CardWidget( selected: gameConfigState.speed == 2, - text: AppLocalizations.of(context)!.txt_fast, + text: L10n.of(context)!.txt_fast, caption: 'x1.25', onTap: () { context @@ -151,7 +148,7 @@ class GameConfigPage extends ConsumerWidget { 'speed': gameConfigState.speed })); }, - child: Text(AppLocalizations.of(context)!.txt_start)), + child: Text(L10n.of(context)!.txt_start)), ), const SizedBox(width: 8) ], diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index af3edf1b..5c81ce77 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -20,7 +20,7 @@ class HomePage extends HookWidget { headerSliverBuilder: (context, innerBoxIsScrolled) { return [ SliverAppBar( - title: Text(AppLocalizations.of(context)!.txt_all_songs, + title: Text(L10n.of(context)!.txt_all_songs, style: Theme.of(context).appBarTheme.textTheme!.headline5), elevation: 2, floating: true, @@ -98,15 +98,15 @@ class HomePage extends HookWidget { String getSongTagName(BuildContext context, String tabName) { switch (tabName) { case 'pop': - return AppLocalizations.of(context)!.pop; + return L10n.of(context)!.pop; case 'classic': - return AppLocalizations.of(context)!.classic; + return L10n.of(context)!.classic; case 'folk': - return AppLocalizations.of(context)!.folk; + return L10n.of(context)!.folk; case 'kpop': - return AppLocalizations.of(context)!.kpop; + return L10n.of(context)!.kpop; case 'other': - return AppLocalizations.of(context)!.other; + return L10n.of(context)!.other; default: return ''; } diff --git a/lib/instrument/instruments_page.dart b/lib/instrument/instruments_page.dart index 81b2f51d..45424a74 100644 --- a/lib/instrument/instruments_page.dart +++ b/lib/instrument/instruments_page.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../loading_widget.dart'; @@ -13,8 +13,7 @@ class InstrumentsPage extends ConsumerWidget { final selectedInstrumentId = watch(selectedInstrumentIdProvider).state; return Scaffold( appBar: AppBar( - title: Text( - AppLocalizations.of(context)!.txt_instrument_title_instruments, + title: Text(L10n.of(context)!.txt_instrument_title_instruments, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: instruments.when( data: (instruments) => ListView.builder( @@ -44,11 +43,11 @@ class InstrumentsPage extends ConsumerWidget { String getInstrumentName(BuildContext context, String instrumentId) { switch (instrumentId) { case 'piano': - return AppLocalizations.of(context)!.piano; + return L10n.of(context)!.piano; case 'acoustic_guitar': - return AppLocalizations.of(context)!.acoustic_guitar; + return L10n.of(context)!.acoustic_guitar; case 'electric_guitar': - return AppLocalizations.of(context)!.electric_guitar; + return L10n.of(context)!.electric_guitar; default: return ''; } diff --git a/lib/locale/locale_page.dart b/lib/locale/locale_page.dart index 1feb4afb..0c312125 100644 --- a/lib/locale/locale_page.dart +++ b/lib/locale/locale_page.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -18,21 +18,20 @@ class LocalePage extends HookWidget { final scrollController = useScrollController(); return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.txt_language, + title: Text(L10n.of(context)!.txt_language, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: Scrollbar( isAlwaysShown: true, controller: scrollController, child: ListView.builder( controller: scrollController, - itemCount: AppLocalizations.supportedLocales.length, + itemCount: L10n.supportedLocales.length, itemBuilder: (context, index) { return RadioListTile( title: Text( - localeStrings[ - AppLocalizations.supportedLocales[index].languageCode]!, + localeStrings[L10n.supportedLocales[index].languageCode]!, style: Theme.of(context).textTheme.headline6), - value: AppLocalizations.supportedLocales[index], + value: L10n.supportedLocales[index], groupValue: Localizations.localeOf(context), onChanged: (value) { context diff --git a/lib/main.dart b/lib/main.dart index 6671f6cf..6d545ab0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -45,8 +45,8 @@ class App extends ConsumerWidget { title: 'Hit Notes', debugShowCheckedModeBanner: false, locale: locale, - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: L10n.localizationsDelegates, + supportedLocales: L10n.supportedLocales, themeMode: themeMode, theme: buildTheme(), darkTheme: buildTheme(isDark: true), diff --git a/lib/setting/settings_page.dart b/lib/setting/settings_page.dart index 96c34cab..0792a9ec 100644 --- a/lib/setting/settings_page.dart +++ b/lib/setting/settings_page.dart @@ -4,7 +4,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:device_info/device_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:in_app_review/in_app_review.dart'; import 'package:package_info/package_info.dart'; @@ -19,13 +19,13 @@ class SettingsPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.txt_settings, + title: Text(L10n.of(context)!.txt_settings, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: ListView( children: [ ListTile( title: Text( - AppLocalizations.of(context)!.txt_language, + L10n.of(context)!.txt_language, style: Theme.of(context).textTheme.headline6, ), subtitle: Text( @@ -35,7 +35,7 @@ class SettingsPage extends StatelessWidget { onTap: () => AutoRouter.of(context).push(const LocaleRoute())), ListTile( title: Text( - AppLocalizations.of(context)!.txt_theme, + L10n.of(context)!.txt_theme, style: Theme.of(context).textTheme.headline6, ), subtitle: Consumer(builder: (context, watch, child) { @@ -46,7 +46,7 @@ class SettingsPage extends StatelessWidget { onTap: () => AutoRouter.of(context).push(const ThemeRoute())), ListTile( title: Text( - AppLocalizations.of(context)!.txt_button_feedback, + L10n.of(context)!.txt_button_feedback, style: Theme.of(context).textTheme.headline6, ), onTap: () async { @@ -88,7 +88,7 @@ class SettingsPage extends StatelessWidget { ), ListTile( title: Text( - AppLocalizations.of(context)!.txt_about_rate, + L10n.of(context)!.txt_about_rate, style: Theme.of(context).textTheme.headline6, ), onTap: () async { diff --git a/lib/theme/theme_page.dart b/lib/theme/theme_page.dart index 86b40c32..2cd44c33 100644 --- a/lib/theme/theme_page.dart +++ b/lib/theme/theme_page.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -11,7 +11,7 @@ class ThemePage extends HookWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.txt_theme, + title: Text(L10n.of(context)!.txt_theme, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: HookBuilder(builder: (context) { final scrollController = useScrollController(); @@ -44,11 +44,11 @@ class ThemePage extends HookWidget { String getThemeName(BuildContext context, ThemeMode themeMode) { switch (themeMode) { case ThemeMode.dark: - return AppLocalizations.of(context)!.dark; + return L10n.of(context)!.dark; case ThemeMode.light: - return AppLocalizations.of(context)!.light; + return L10n.of(context)!.light; case ThemeMode.system: - return AppLocalizations.of(context)!.system; + return L10n.of(context)!.system; default: return ''; } diff --git a/lib/user/user_page.dart b/lib/user/user_page.dart index 3f14194a..5a112388 100644 --- a/lib/user/user_page.dart +++ b/lib/user/user_page.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:intl/intl.dart'; @@ -16,7 +16,7 @@ class UserPage extends HookWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.txt_page_title_account, + title: Text(L10n.of(context)!.txt_page_title_account, style: Theme.of(context).appBarTheme.textTheme!.headline5)), body: HookBuilder(builder: (context) { final user = useProvider(userProvider); @@ -189,7 +189,7 @@ class UserPage extends HookWidget { ), const SizedBox(width: 8), Text( - sprintf(AppLocalizations.of(context)!.txt_joined, + sprintf(L10n.of(context)!.txt_joined, [DateFormat.yMMMd().format(user.creationTime)]), style: Theme.of(context).textTheme.subtitle1, ), @@ -203,7 +203,7 @@ class UserPage extends HookWidget { height: 16, ), const SizedBox(width: 8), - Text(sprintf(AppLocalizations.of(context)!.txt_using, + Text(sprintf(L10n.of(context)!.txt_using, [getInstrumentName(context, user.instrumentId)])), ], ),