Implemented localization across the application.
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Failing after 2m22s

This commit is contained in:
2026-01-01 00:21:09 +01:00
parent d9a26a8cf7
commit 534d19efc3
17 changed files with 247 additions and 157 deletions

View File

@@ -3,6 +3,7 @@ import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_list_tile.dart';
@@ -129,14 +130,20 @@ class _PlayerSelectionState extends State<PlayerSelection> {
),
const SizedBox(height: 10),
Text(
'Selected players: (${selectedPlayers.length})',
AppLocalizations.of(
context,
)!.selected_players(selectedPlayers.length),
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
SizedBox(
height: 50,
child: selectedPlayers.isEmpty
? const Center(child: Text('No players selected'))
? Center(
child: Text(
AppLocalizations.of(context)!.no_players_selected,
),
)
: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
@@ -171,8 +178,8 @@ class _PlayerSelectionState extends State<PlayerSelection> {
),
),
const SizedBox(height: 10),
const Text(
'All players:',
Text(
AppLocalizations.of(context)!.all_players,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
@@ -186,12 +193,14 @@ class _PlayerSelectionState extends State<PlayerSelection> {
visible: suggestedPlayers.isNotEmpty,
replacement: TopCenteredMessage(
icon: Icons.info,
title: 'Info',
title: AppLocalizations.of(context)!.info,
message: allPlayers.isEmpty
? 'No players created yet'
? AppLocalizations.of(context)!.no_players_created_yet
: (selectedPlayers.length == allPlayers.length)
? 'No more players to add'
: 'No players found with that name',
? AppLocalizations.of(context)!.all_players_selected
: AppLocalizations.of(
context,
)!.no_players_found_with_that_name,
),
child: ListView.builder(
itemCount: suggestedPlayers.length,
@@ -243,7 +252,9 @@ class _PlayerSelectionState extends State<PlayerSelection> {
backgroundColor: CustomTheme.boxColor,
content: Center(
child: Text(
'Successfully added player $playerName.',
AppLocalizations.of(
context,
)!.successfully_added_player(playerName),
style: const TextStyle(color: Colors.white),
),
),
@@ -255,7 +266,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
backgroundColor: CustomTheme.boxColor,
content: Center(
child: Text(
'Could not add player $playerName.',
AppLocalizations.of(context)!.could_not_add_player(playerName),
style: const TextStyle(color: Colors.white),
),
),

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
import 'package:intl/intl.dart';
@@ -97,7 +98,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
const SizedBox(width: 8),
Expanded(
child: Text(
'Winner: ${winner.name}',
AppLocalizations.of(context)!.winner(winner.name),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
@@ -113,8 +114,8 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
],
if (allPlayers.isNotEmpty) ...[
const Text(
'Players',
Text(
AppLocalizations.of(context)!.players,
style: TextStyle(
fontSize: 13,
color: Colors.grey,
@@ -141,11 +142,15 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
final difference = now.difference(dateTime);
if (difference.inDays == 0) {
return 'Today at ${DateFormat('HH:mm').format(dateTime)}';
return AppLocalizations.of(
context,
)!.today_at(DateFormat('HH:mm').format(dateTime));
} else if (difference.inDays == 1) {
return 'Yesterday at ${DateFormat('HH:mm').format(dateTime)}';
return AppLocalizations.of(
context,
)!.yesterday_at(DateFormat('HH:mm').format(dateTime));
} else if (difference.inDays < 7) {
return '${difference.inDays} days ago';
return AppLocalizations.of(context)!.days_ago(difference.inDays);
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}

View File

@@ -1,6 +1,7 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart';
class StatisticsTile extends StatelessWidget {
@@ -33,9 +34,9 @@ class StatisticsTile extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Visibility(
visible: values.isNotEmpty,
replacement: const Center(
replacement: Center(
heightFactor: 4,
child: Text('No data available.'),
child: Text(AppLocalizations.of(context)!.no_data_available),
),
child: Column(
children: List.generate(min(values.length, itemCount), (index) {