Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
Shorten name of L10n generated class
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong0993 committed May 26, 2021
1 parent 1ec7618 commit dc71c21
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 79 deletions.
3 changes: 2 additions & 1 deletion l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
arb-dir: lib/l10n
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
output-localization-file: l10n.dart
output-class: L10n
10 changes: 3 additions & 7 deletions lib/authentication/authentication_widget.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)
],
),
Expand All @@ -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)
],
),
Expand Down
7 changes: 3 additions & 4 deletions lib/game/complete_widget.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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),
Expand All @@ -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)
],
Expand Down
14 changes: 6 additions & 8 deletions lib/game/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
],
)),
),
Expand Down Expand Up @@ -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)
],
)),
),
Expand Down
9 changes: 4 additions & 5 deletions lib/game/pause_dialog.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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),
)
],
),
Expand Down
31 changes: 14 additions & 17 deletions lib/game_config/game_config_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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(
Expand All @@ -32,17 +32,16 @@ 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(
children: [
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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -84,15 +81,15 @@ 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(
children: [
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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
],
Expand Down
14 changes: 7 additions & 7 deletions lib/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -20,7 +20,7 @@ class HomePage extends HookWidget {
headerSliverBuilder: (context, innerBoxIsScrolled) {
return <Widget>[
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,
Expand Down Expand Up @@ -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 '';
}
Expand Down
11 changes: 5 additions & 6 deletions lib/instrument/instruments_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(
Expand Down Expand Up @@ -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 '';
}
Expand Down
11 changes: 5 additions & 6 deletions lib/locale/locale_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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<Locale>(
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
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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),
Expand Down
Loading

0 comments on commit dc71c21

Please sign in to comment.