feat: 全量英文界面(i18n 翻译表接入全部页面与服务层文案)
This commit is contained in:
1 parent
2eb3f42731
commit
71e76b1c2b
26 files changed
+775
-325
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
/// 快速命令预设。
|
||||
class QuickCommandPreset {
|
||||
@@ -22,16 +23,16 @@ class CommandPresetService {
|
||||
static const _key = 'mc_quick_commands_v1';
|
||||
|
||||
/// 默认预设,首次使用或清空后恢复。
|
||||
static const defaultPresets = <QuickCommandPreset>[
|
||||
QuickCommandPreset(label: '在线列表', command: 'list'),
|
||||
QuickCommandPreset(label: '立即存档', command: 'save-all'),
|
||||
QuickCommandPreset(label: '查看种子', command: 'seed'),
|
||||
QuickCommandPreset(label: '晴天', command: 'weather clear'),
|
||||
QuickCommandPreset(label: '设为白天', command: 'time set day'),
|
||||
QuickCommandPreset(label: '设为黑夜', command: 'time set night'),
|
||||
QuickCommandPreset(label: '和平难度', command: 'difficulty peaceful'),
|
||||
QuickCommandPreset(label: '白名单列表', command: 'whitelist list'),
|
||||
QuickCommandPreset(label: '在线公告', command: 'say 服务器已在线,欢迎游玩!'),
|
||||
static List<QuickCommandPreset> get defaultPresets => <QuickCommandPreset>[
|
||||
QuickCommandPreset(label: S.t('在线列表'), command: 'list'),
|
||||
QuickCommandPreset(label: S.t('立即存档'), command: 'save-all'),
|
||||
QuickCommandPreset(label: S.t('查看种子'), command: 'seed'),
|
||||
QuickCommandPreset(label: S.t('晴天'), command: 'weather clear'),
|
||||
QuickCommandPreset(label: S.t('设为白天'), command: 'time set day'),
|
||||
QuickCommandPreset(label: S.t('设为黑夜'), command: 'time set night'),
|
||||
QuickCommandPreset(label: S.t('和平难度'), command: 'difficulty peaceful'),
|
||||
QuickCommandPreset(label: S.t('白名单列表'), command: 'whitelist list'),
|
||||
QuickCommandPreset(label: S.t('在线公告'), command: 'say 服务器已在线,欢迎游玩!'),
|
||||
];
|
||||
|
||||
static Future<List<QuickCommandPreset>> load() async {
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'rcon_stream_parser.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
/// 去除 Minecraft 消息中的颜色/格式码(§ 后跟一个有效字符)。
|
||||
String stripMinecraftCodes(String input) {
|
||||
@@ -72,7 +73,7 @@ class RconClient {
|
||||
|
||||
Future<String?> executeCommand(String command) async {
|
||||
if (!_isAuthenticated || _socket == null) {
|
||||
throw Exception('RCON 未连接或未认证');
|
||||
throw Exception(S.t('RCON 未连接或未认证'));
|
||||
}
|
||||
final response = await _sendPacket(2, command);
|
||||
return response?.payload;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
/// 软件更新信息,由 Gitee 发布接口的 tag_name 与 assets 解析而来
|
||||
class UpdateInfo {
|
||||
@@ -91,20 +92,20 @@ class UpdateService {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(hasUpdate ? '发现新版本' : '已是最新'),
|
||||
title: Text(hasUpdate ? S.t('发现新版本') : S.t('已是最新')),
|
||||
content: Text(hasUpdate
|
||||
? '最新版本: ${info.latestVersion}\n当前版本: $currentVersion'
|
||||
: '当前版本 $currentVersion 已是最新'),
|
||||
: S.f('当前版本 {0} 已是最新', [currentVersion])),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context), child: const Text('关闭')),
|
||||
onPressed: () => Navigator.pop(context), child: T('关闭')),
|
||||
if (hasUpdate)
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
downloadAndInstall(context, info);
|
||||
},
|
||||
child: const Text('立即更新'),
|
||||
child: T('立即更新'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -116,13 +117,13 @@ class UpdateService {
|
||||
BuildContext context, UpdateInfo info) async {
|
||||
if (_downloading) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('正在下载,请稍候…')),
|
||||
SnackBar(content: T('正在下载,请稍候…')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (info.downloadUrl.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('未找到可下载的安装包')),
|
||||
const SnackBar(content: T('未找到可下载的安装包')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -152,7 +153,7 @@ class UpdateService {
|
||||
builder: (_) => PopScope(
|
||||
canPop: false,
|
||||
child: AlertDialog(
|
||||
title: const Text('正在下载更新'),
|
||||
title: T('正在下载更新'),
|
||||
content: ValueListenableBuilder<double?>(
|
||||
valueListenable: progress,
|
||||
builder: (context, value, _) {
|
||||
@@ -163,7 +164,7 @@ class UpdateService {
|
||||
CircularProgressIndicator(value: value),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
percent == null ? '正在下载安装包…' : '下载中:$percent%',
|
||||
percent == null ? S.t('正在下载安装包…') : S.f('下载中:{0}%', [percent]),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
@@ -183,7 +184,7 @@ class UpdateService {
|
||||
final message = e.message?.toString() ?? e.code;
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('更新失败:$message')),
|
||||
SnackBar(content: Text(S.f('更新失败:{0}', [message]))),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user