Skip to content

Commit

Permalink
[minesweeper] 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 736bcb6 commit 4212aaa
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 46 deletions.
12 changes: 4 additions & 8 deletions assets/l10n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,18 @@ game:
navigation: Game
newGame: New game
continueGame: Continue
tryAgain: Try again
youWin: You win
gameOver: Game over
2048:
title: 2048
score: Score
best: Best
newGame: New game
tryAgain: Try again
youWin: You win
gameOver: Game over
minesweeper:
title: Minesweeper
timeSpent: "You spent {}"
gameMode:
easy: Easy
gameOver:
failed: Failed
won: Won
restart: Restart
dormitoryRoom: "Building {building} #{room}"
open: Open
delete: Delete
Expand Down
12 changes: 4 additions & 8 deletions assets/l10n/zh-Hans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,18 @@ game:
navigation: 游戏
newGame: 新游戏
continueGame: 继续游戏
tryAgain: 再试一次
youWin: 你赢了!
gameOver: 游戏结束
2048:
title: 2048
score: 分数
best: 最佳
newGame: 新游戏
tryAgain: 再试一次
youWin: 你赢了!
gameOver: 游戏结束
minesweeper:
title: 扫雷
timeSpent: "用时 {}"
gameMode:
easy: 简单
gameOver:
failed: 失败
won: 获胜
restart: 再试一次
dormitoryRoom: "{building}号楼 #{room}"
open: 打开
delete: 删除
Expand Down
12 changes: 4 additions & 8 deletions assets/l10n/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,18 @@ game:
navigation: 電玩
newGame: 新遊戲
continueGame: 繼續
tryAgain: 再試一次
youWin: 你獲勝了!
gameOver: Game over
2048:
title: 2048
score: 分數
best: 最佳
newGame: 新遊戲
tryAgain: 再試一次
youWin: 你獲勝了!
gameOver: Game over
minesweeper:
title: 掃雷
timeSpent: "用時 {}"
gameMode:
easy: 簡單
gameOver:
failed: 失敗
won: 勝利
restart: 再玩一次
dormitoryRoom: "{building}號樓 #{room}"
open: 打開
delete: 刪除
Expand Down
11 changes: 2 additions & 9 deletions lib/game/2048/i18n.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:sit/game/i18n.dart';
import 'package:sit/l10n/common.dart';

const i18n = _I18n();

class _I18n with CommonI18nMixin {
class _I18n with CommonI18nMixin, CommonGameI18nMixin {
const _I18n();

static const ns = "game.2048";
Expand All @@ -13,12 +14,4 @@ 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();
}
17 changes: 13 additions & 4 deletions lib/game/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:sit/l10n/common.dart';

const i18n = _I18n();
const _ns = "game";

class _I18n with CommonI18nMixin {
const _I18n();

static const ns = "game";
String get navigation => "$_ns.navigation".tr();

String get navigation => "$ns.navigation".tr();
String get newGame => "$_ns.newGame".tr();

String get newGame => "$ns.newGame".tr();
String get continueGame => "$_ns.continueGame".tr();
}

mixin class CommonGameI18nMixin {
String get newGame => "$_ns.newGame".tr();

String get tryAgain => "$_ns.tryAgain".tr();

String get youWin => "$_ns.youWin".tr();

String get continueGame => "$ns.continueGame".tr();
String get gameOver => "$_ns.gameOver".tr();
}
9 changes: 3 additions & 6 deletions lib/game/minesweeper/i18n.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:sit/game/i18n.dart';
import 'package:sit/game/minesweeper/model/mode.dart';
import 'package:sit/l10n/common.dart';

const i18n = _I18n();

class _I18n with CommonI18nMixin {
class _I18n with CommonI18nMixin, CommonGameI18nMixin {
const _I18n();

static const ns = "game.minesweeper";

String get title => "$ns.title".tr();

String get gameOverFailed => "$ns.gameOver.failed".tr();

String get gameOverWon => "$ns.gameOver.won".tr();

String get restart => "$ns.restart".tr();
String timeSpent(String time) => "$ns.timeSpent".tr(args: [time]);
}

extension GameModeI18nX on GameMode {
Expand Down
10 changes: 7 additions & 3 deletions lib/game/minesweeper/widget/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../manager/logic.dart';
import '../manager/timer.dart';
import '../theme.dart';
import '../i18n.dart';

class GameOverModal extends ConsumerWidget {
const GameOverModal({
Expand Down Expand Up @@ -38,8 +39,11 @@ class GameOverModal extends ConsumerWidget {
resetGame();
},
child: Text(
"Game Over!\n Click To Restart",
style: TextStyle(color: gameOverTextColor, fontSize: textSize),
i18n.gameOver,
style: TextStyle(
color: gameOverTextColor,
fontSize: textSize,
),
),
),
),
Expand All @@ -65,7 +69,7 @@ class GameOverModal extends ConsumerWidget {
resetGame();
},
child: Text(
" You Win!\n Time: $costTime \n Click To Play Again",
"${i18n.youWin}\n${i18n.timeSpent(costTime)}",
style: TextStyle(color: goodGameTextColor, fontSize: textSize),
),
),
Expand Down

0 comments on commit 4212aaa

Please sign in to comment.