Skip to content

Commit

Permalink
fix: replace hard-coded strings with l10n (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip Pramanik authored Aug 8, 2024
1 parent 6b9fd18 commit 29bdc5a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/home/widgets/player_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:sudoku/assets/assets.dart';
import 'package:sudoku/colors/colors.dart';
import 'package:sudoku/home/home.dart';
import 'package:sudoku/l10n/l10n.dart';
import 'package:sudoku/layout/layout.dart';
import 'package:sudoku/typography/typography.dart';
import 'package:sudoku/widgets/widgets.dart';
Expand All @@ -12,6 +13,7 @@ class PlayerInfoWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final player = context.select((HomeBloc bloc) => bloc.state.player);

return ResponsiveLayoutBuilder(
Expand Down Expand Up @@ -47,15 +49,15 @@ class PlayerInfoWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
'Player Stats',
l10n.playerStatsTitle,
style: SudokuTextStyle.bodyText1.copyWith(
fontWeight: SudokuFontWeight.bold,
color: Colors.white,
),
maxLines: 1,
),
Text(
'Solved / Attempted',
l10n.solvedVsAttemptedText,
style: SudokuTextStyle.bodyText1.copyWith(
fontWeight: SudokuFontWeight.medium,
fontSize: 12,
Expand All @@ -68,15 +70,15 @@ class PlayerInfoWidget extends StatelessWidget {
children: [
Expanded(
child: AttemptedVsSolved(
label: 'Easy',
label: l10n.statsPerDifficulty('easy'),
attempted: player.easyAttempted,
solved: player.easySolved,
),
),
const SizedBox(width: 32),
Expanded(
child: AttemptedVsSolved(
label: 'Medium',
label: l10n.statsPerDifficulty('medium'),
attempted: player.mediumAttempted,
solved: player.mediumSolved,
),
Expand All @@ -88,15 +90,15 @@ class PlayerInfoWidget extends StatelessWidget {
children: [
Expanded(
child: AttemptedVsSolved(
label: 'Difficult',
label: l10n.statsPerDifficulty('difficult'),
attempted: player.difficultAttempted,
solved: player.difficultSolved,
),
),
const SizedBox(width: 32),
Expanded(
child: AttemptedVsSolved(
label: 'Expert',
label: l10n.statsPerDifficulty('expert'),
attempted: player.expertAttempted,
solved: player.expertSolved,
),
Expand Down Expand Up @@ -160,15 +162,15 @@ class PlayerInfoWidget extends StatelessWidget {
),
const SizedBox(height: 16),
Text(
'Player Stats',
l10n.playerStatsTitle,
style: titleTextStyle.copyWith(
fontWeight: SudokuFontWeight.bold,
color: Colors.white,
),
maxLines: 1,
),
Text(
'Solved / Attempted',
l10n.solvedVsAttemptedText,
style: titleTextStyle.copyWith(
fontWeight: SudokuFontWeight.medium,
fontSize: 12,
Expand All @@ -178,25 +180,25 @@ class PlayerInfoWidget extends StatelessWidget {
),
const SizedBox(height: 8),
AttemptedVsSolved(
label: 'Easy',
label: l10n.statsPerDifficulty('easy'),
attempted: player.easyAttempted,
solved: player.easySolved,
),
const SizedBox(height: 2),
AttemptedVsSolved(
label: 'Medium',
label: l10n.statsPerDifficulty('medium'),
attempted: player.mediumAttempted,
solved: player.mediumSolved,
),
const SizedBox(height: 2),
AttemptedVsSolved(
label: 'Difficult',
label: l10n.statsPerDifficulty('difficult'),
attempted: player.difficultAttempted,
solved: player.difficultSolved,
),
const SizedBox(height: 2),
AttemptedVsSolved(
label: 'Expert',
label: l10n.statsPerDifficulty('expert'),
attempted: player.expertAttempted,
solved: player.expertSolved,
),
Expand Down
17 changes: 17 additions & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,22 @@
"competitionBannerCta": "Read More -->",
"@competitionBannerCta": {
"description": "Text shown as the CTA for Competition Banner in the Home Page"
},
"playerStatsTitle": "Player Stats",
"@playerStatsTitle": {
"description": "Text shown in the Player Stats card in home page"
},
"solvedVsAttemptedText": "Solved / Attempted",
"@solvedVsAttemptedText": {
"description": "Text shown as a caption in Player Stats card in Home Page"
},
"statsPerDifficulty": "{difficulty, select, easy{Easy} medium{Medium} difficult{Difficult} expert{Expert} other{Others}}",
"@statsPerDifficulty": {
"description": "Text shown in the Player Stats card in home page",
"placeholders": {
"difficulty": {
"type": "String"
}
}
}
}

0 comments on commit 29bdc5a

Please sign in to comment.