From 736bcb6cb6db6949cea3eb0c335248453885c08b Mon Sep 17 00:00:00 2001 From: Liplum Date: Fri, 22 Mar 2024 09:20:19 +0800 Subject: [PATCH] [2048] i18n of game over --- assets/l10n/en.yaml | 4 ++++ assets/l10n/zh-Hans.yaml | 4 ++++ assets/l10n/zh-Hant.yaml | 6 +++++- lib/game/2048/i18n.dart | 8 ++++++++ lib/game/2048/widget/tile_board.dart | 5 +++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/assets/l10n/en.yaml b/assets/l10n/en.yaml index 996719b78..9ef275e79 100644 --- a/assets/l10n/en.yaml +++ b/assets/l10n/en.yaml @@ -759,6 +759,10 @@ game: title: 2048 score: Score best: Best + newGame: New game + tryAgain: Try again + youWin: You win + gameOver: Game over minesweeper: title: Minesweeper gameMode: diff --git a/assets/l10n/zh-Hans.yaml b/assets/l10n/zh-Hans.yaml index 0428d36a9..e8c33f77b 100644 --- a/assets/l10n/zh-Hans.yaml +++ b/assets/l10n/zh-Hans.yaml @@ -759,6 +759,10 @@ game: title: 2048 score: 分数 best: 最佳 + newGame: 新游戏 + tryAgain: 再试一次 + youWin: 你赢了! + gameOver: 游戏结束 minesweeper: title: 扫雷 gameMode: diff --git a/assets/l10n/zh-Hant.yaml b/assets/l10n/zh-Hant.yaml index 60576b08d..19c8e25d9 100644 --- a/assets/l10n/zh-Hant.yaml +++ b/assets/l10n/zh-Hant.yaml @@ -753,12 +753,16 @@ OaUserType: other: 其他 game: navigation: 電玩 - newGame: 創建 + newGame: 新遊戲 continueGame: 繼續 2048: title: 2048 score: 分數 best: 最佳 + newGame: 新遊戲 + tryAgain: 再試一次 + youWin: 你獲勝了! + gameOver: Game over minesweeper: title: 掃雷 gameMode: diff --git a/lib/game/2048/i18n.dart b/lib/game/2048/i18n.dart index 9e3e7cc10..d3e808241 100644 --- a/lib/game/2048/i18n.dart +++ b/lib/game/2048/i18n.dart @@ -13,4 +13,12 @@ class _I18n with CommonI18nMixin { String get score => "$ns.score".tr(); String get best => "$ns.best".tr(); + + String get newGame => "$ns.newGame".tr(); + + String get tryAgain => "$ns.tryAgain".tr(); + + String get youWin => "$ns.youWin".tr(); + + String get gameOver => "$ns.gameOver".tr(); } diff --git a/lib/game/2048/widget/tile_board.dart b/lib/game/2048/widget/tile_board.dart index dd0126a8f..7f616c1ae 100644 --- a/lib/game/2048/widget/tile_board.dart +++ b/lib/game/2048/widget/tile_board.dart @@ -6,6 +6,7 @@ import 'package:rettulf/rettulf.dart'; import 'package:sit/game/2048/widget/tile.dart'; import '../theme.dart'; +import '../i18n.dart'; import '../manager/board.dart'; import 'animated_tile.dart'; @@ -70,11 +71,11 @@ class TileBoardWidget extends ConsumerWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - board.won ? 'You win!' : 'Game over!', + board.won ? i18n.youWin : i18n.gameOver, style: const TextStyle(color: textColor, fontWeight: FontWeight.bold, fontSize: 64.0), ), ButtonWidget( - text: board.won ? 'New Game' : 'Try again', + text: board.won ? i18n.newGame : i18n.tryAgain, onPressed: () { ref.read(boardManager.notifier).newGame(); },