Skip to content

Commit

Permalink
[2048] i18n of game over
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Mar 22, 2024
1 parent c8132eb commit 736bcb6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions assets/l10n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions assets/l10n/zh-Hans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,10 @@ game:
title: 2048
score: 分数
best: 最佳
newGame: 新游戏
tryAgain: 再试一次
youWin: 你赢了!
gameOver: 游戏结束
minesweeper:
title: 扫雷
gameMode:
Expand Down
6 changes: 5 additions & 1 deletion assets/l10n/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions lib/game/2048/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
5 changes: 3 additions & 2 deletions lib/game/2048/widget/tile_board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
},
Expand Down

0 comments on commit 736bcb6

Please sign in to comment.