feat: 全量英文界面(i18n 翻译表接入全部页面与服务层文案)

This commit is contained in:
ZV Team committed 2026-10-24 09:39:51 +08:00
1 parent 2eb3f42731
commit 71e76b1c2b
26 files changed
+775 -325

No files matched your search

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../providers/download_provider.dart';
import '../../core/l10n/strings.dart';
/// 下载与镜像设置页:镜像线路选择、测速自动选线、并发数(原下载页内设置移入此处)。
class DownloadSettingsPage extends StatefulWidget {
@@ -24,13 +25,13 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
final dp = context.watch<DownloadProvider>();
final mirror = dp.mirror;
return Scaffold(
appBar: AppBar(title: const Text('下载与镜像设置')),
appBar: AppBar(title: T('下载与镜像设置')),
body: ListView(
children: [
const SectionHeader('镜像线路'),
RadioListTile<String>(
title: const Text('MCIM 国内镜像(推荐)'),
subtitle: const Text('modrinth.mcimirror.top,无需科学上网'),
title: T('MCIM 国内镜像(推荐)'),
subtitle: T('modrinth.mcimirror.top,无需科学上网'),
value: 'mcim',
groupValue: mirror.currentId,
onChanged: (v) async {
@@ -39,8 +40,8 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
},
),
RadioListTile<String>(
title: const Text('Modrinth 官方'),
subtitle: const Text('直连官方源,适合海外网络'),
title: T('Modrinth 官方'),
subtitle: T('直连官方源,适合海外网络'),
value: 'official',
groupValue: mirror.currentId,
onChanged: (v) async {
@@ -49,7 +50,7 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
},
),
RadioListTile<String>(
title: const Text('自定义镜像'),
title: T('自定义镜像'),
subtitle: Text(mirror.currentId == 'custom' && mirror.customUrl.isNotEmpty
? mirror.customUrl
: '使用自建/第三方镜像地址'),
@@ -61,9 +62,9 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
leading: _testing
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.speed),
title: const Text('一键测速并选择最快线路'),
title: T('一键测速并选择最快线路'),
subtitle: Text(mirror.lastSpeedMs > 0
? '上次测速:${mirror.lastSpeedMs}ms(${mirror.currentName})'
? S.f('上次测速:{0}ms({1})', [mirror.lastSpeedMs, mirror.currentName])
: '自动在官方与镜像之间选择延迟最低的线路'),
onTap: _testing
? null
@@ -74,7 +75,7 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
if (!mounted) return;
setState(() => _testing = false);
messenger.showSnackBar(SnackBar(
content: Text('已选择最快线路:${mirror.currentName}(${mirror.lastSpeedMs}ms)'),
content: Text(S.f('已选择最快线路:{0}({1}ms)', [mirror.currentName, mirror.lastSpeedMs])),
));
},
),
@@ -82,8 +83,8 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
const SectionHeader('下载队列'),
ListTile(
leading: const Icon(Icons.playlist_play),
title: const Text('同时下载任务数'),
subtitle: Text('当前:${dp.concurrency} 个(越大越占带宽,建议 1-3)'),
title: T('同时下载任务数'),
subtitle: Text(S.f('当前:{0} 个(越大越占带宽,建议 1-3)', [dp.concurrency])),
trailing: DropdownButton<int>(
value: dp.concurrency,
underline: const SizedBox.shrink(),
@@ -117,14 +118,14 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {
final url = await showDialog<String>(
context: context,
builder: (_) => AlertDialog(
title: const Text('自定义镜像地址'),
title: T('自定义镜像地址'),
content: TextField(
controller: ctrl,
decoration: const InputDecoration(hintText: 'https://your-mirror.example.com'),
decoration: InputDecoration(hintText: 'https://your-mirror.example.com'),
),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
FilledButton(onPressed: () => Navigator.pop(context, ctrl.text.trim()), child: const Text('确定')),
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
FilledButton(onPressed: () => Navigator.pop(context, ctrl.text.trim()), child: T('确定')),
],
),
);
+6 -6
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../core/l10n/strings.dart';
/// 使用教程页:教用户如何开启 RCON、SSH、使用模组管理/下载/终端等功能。
class HelpPage extends StatelessWidget {
@@ -7,7 +8,7 @@ class HelpPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('使用教程')),
appBar: AppBar(title: Text(S.t('使用教程'))),
body: ListView(
padding: const EdgeInsets.all(12),
children: const [
@@ -124,8 +125,7 @@ class _Intro extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(14),
child: Text(
'本页教您一步步开启并使用 ZV Manager 的各项功能。\n'
'首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。',
'''${S.t('本页教您一步步开启并使用 ZV Manager 的各项功能。')}\n${S.t('首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。')}''',
style: Theme.of(context).textTheme.bodyMedium,
),
),
@@ -153,7 +153,7 @@ class _TutorialCard extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 6),
child: ExpansionTile(
leading: Icon(icon),
title: Text(title, style: theme.textTheme.titleSmall),
title: Text(S.t(title), style: theme.textTheme.titleSmall),
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 14),
expandedCrossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -166,7 +166,7 @@ class _TutorialCard extends StatelessWidget {
style: TextStyle(
fontWeight: FontWeight.w600,
color: theme.colorScheme.primary)),
Expanded(child: Text(e.value)),
Expanded(child: Text(S.t(e.value))),
],
),
)),
@@ -184,7 +184,7 @@ class _TutorialCard extends StatelessWidget {
children: tips
.map((t) => Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Text(t, style: theme.textTheme.bodySmall),
child: Text(S.t(t), style: theme.textTheme.bodySmall),
))
.toList(),
),
+26 -25
View File
@@ -14,6 +14,7 @@ import '../../providers/wallpaper_provider.dart';
import 'help_page.dart';
import 'download_settings_page.dart';
import '../../providers/language_provider.dart';
import '../../core/l10n/strings.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@@ -65,7 +66,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (updateInfo == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('获取更新信息失败')),
SnackBar(content: T('获取更新信息失败')),
);
return;
}
@@ -75,7 +76,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (!mounted) return;
setState(() => _checkingUpdate = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('检查更新失败:$e')),
SnackBar(content: Text(S.f('检查更新失败:{0}', [e]))),
);
}
}
@@ -90,7 +91,7 @@ class _SettingsPageState extends State<SettingsPage> {
children: [
ListTile(
leading: const Icon(Icons.photo, color: Colors.blue),
title: const Text('选择图片'),
title: T('选择图片'),
onTap: () {
Navigator.pop(ctx);
_pickImage();
@@ -98,7 +99,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
ListTile(
leading: const Icon(Icons.videocam, color: Colors.green),
title: const Text('选择视频'),
title: T('选择视频'),
onTap: () {
Navigator.pop(ctx);
_pickVideo();
@@ -108,7 +109,7 @@ class _SettingsPageState extends State<SettingsPage> {
const Divider(),
ListTile(
leading: const Icon(Icons.delete, color: Colors.red),
title: const Text('清除背景', style: TextStyle(color: Colors.red)),
title: T('清除背景', style: TextStyle(color: Colors.red)),
onTap: () {
Navigator.pop(ctx);
_clearBackground();
@@ -145,7 +146,7 @@ class _SettingsPageState extends State<SettingsPage> {
final mode = await showDialog<LanguageMode>(
context: context,
builder: (_) => SimpleDialog(
title: const Text('语言 / Language'),
title: T('语言 / Language'),
children: [
for (final m in LanguageMode.values)
RadioListTile<LanguageMode>(
@@ -184,7 +185,7 @@ class _SettingsPageState extends State<SettingsPage> {
debugPrint('保存壁纸设置失败: $e');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('壁纸设置保存失败,请重试')),
SnackBar(content: T('壁纸设置保存失败,请重试')),
);
}
return false;
@@ -209,7 +210,7 @@ class _SettingsPageState extends State<SettingsPage> {
debugPrint('保存失败: $e');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('保存失败,请重试')),
SnackBar(content: T('保存失败,请重试')),
);
}
return null;
@@ -244,7 +245,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(_currentBgPath == null ? '已清除背景' : '背景已更新 '),
content: Text(_currentBgPath == null ? S.t('已清除背景') : S.t('背景已更新')),
duration: const Duration(seconds: 1),
),
);
@@ -258,13 +259,13 @@ class _SettingsPageState extends State<SettingsPage> {
final themeProvider = context.watch<ThemeProvider>();
return Scaffold(
appBar: AppBar(title: const Text('设置')),
appBar: AppBar(title: T('设置')),
body: ListView(
children: [
// ---------- 外观主题 ----------
ListTile(
leading: const Icon(Icons.palette_outlined),
title: const Text('外观主题'),
title: T('外观主题'),
trailing: SegmentedButton<AppThemeMode>(
segments: const [
ButtonSegment(value: AppThemeMode.light, icon: Icon(Icons.light_mode, size: 18)),
@@ -281,11 +282,11 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 应用背景(新增) ----------
ListTile(
leading: const Icon(Icons.wallpaper),
title: const Text('应用背景'),
title: T('应用背景'),
subtitle: Text(
_currentBgPath == null
? '未设置'
: '已设置 ${_currentBgType == 'video' ? ' 视频' : ' 图片'}',
: S.f('已设置 {0}', [_currentBgType == 'video' ? S.t('视频') : S.t('图片')]),
),
trailing: const Icon(Icons.arrow_forward_ios, size: 16),
onTap: _showBackgroundPicker,
@@ -294,8 +295,8 @@ class _SettingsPageState extends State<SettingsPage> {
if (_currentBgType == 'video') ...[
SwitchListTile(
secondary: const Icon(Icons.volume_up),
title: const Text('视频声音'),
subtitle: const Text('开启后背景视频将播放声音'),
title: T('视频声音'),
subtitle: T('开启后背景视频将播放声音'),
value: _videoSoundEnabled,
onChanged: (value) async {
await BackgroundService.setVideoSound(value);
@@ -310,7 +311,7 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 语言 ----------
ListTile(
leading: const Icon(Icons.language),
title: const Text('语言 / Language'),
title: T('语言 / Language'),
subtitle: Text(_languageName(context.watch<LanguageProvider>().mode)),
trailing: const Icon(Icons.chevron_right),
onTap: () => _pickLanguage(),
@@ -320,8 +321,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 下载与镜像 ----------
ListTile(
leading: const Icon(Icons.download_outlined),
title: const Text('下载与镜像设置'),
subtitle: const Text('镜像线路、测速选线、同时下载任务数'),
title: T('下载与镜像设置'),
subtitle: T('镜像线路、测速选线、同时下载任务数'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
@@ -333,8 +334,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 使用教程 ----------
ListTile(
leading: const Icon(Icons.menu_book_outlined),
title: const Text('使用教程'),
subtitle: const Text('如何开启 RCON / SSH、模组管理、下载与终端'),
title: T('使用教程'),
subtitle: T('如何开启 RCON / SSH、模组管理、下载与终端'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
@@ -346,8 +347,8 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 检查更新 ----------
ListTile(
leading: const Icon(Icons.system_update_outlined),
title: const Text('检查更新'),
subtitle: Text('当前版本: $_currentVersion'),
title: T('检查更新'),
subtitle: Text(S.f('当前版本: {0}', [_currentVersion])),
trailing: _checkingUpdate
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.chevron_right),
@@ -358,15 +359,15 @@ class _SettingsPageState extends State<SettingsPage> {
// ---------- 关于 ----------
const ListTile(
leading: Icon(Icons.info_outline),
title: Text('关于'),
subtitle: Text('开发者:Z有3笔,协作者:venti1112'),
title: T('关于'),
subtitle: T('开发者:Z有3笔,协作者:venti1112'),
),
const Divider(),
// ---------- 开源许可 ----------
ListTile(
leading: const Icon(Icons.fact_check_outlined),
title: const Text('开源许可'),
title: T('开源许可'),
onTap: () => showLicensePage(context: context),
),
],
+18 -17
View File
@@ -4,6 +4,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import '../../providers/wallpaper_provider.dart';
import '../../core/l10n/strings.dart';
class WallpaperSettings extends StatelessWidget {
const WallpaperSettings({super.key});
@@ -15,7 +16,7 @@ class WallpaperSettings extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('壁纸设置'),
title: T('壁纸设置'),
backgroundColor: theme.colorScheme.primary,
foregroundColor: Colors.white,
),
@@ -42,8 +43,8 @@ class WallpaperSettings extends StatelessWidget {
children: [
Icon(Icons.wallpaper, size: 48, color: Colors.grey),
SizedBox(height: 8),
Text('当前为默认壁纸', style: TextStyle(color: Colors.grey)),
Text('点击下方「选择图片」自定义', style: TextStyle(color: Colors.grey, fontSize: 12)),
T('当前为默认壁纸', style: TextStyle(color: Colors.grey)),
T('点击下方「选择图片」自定义', style: TextStyle(color: Colors.grey, fontSize: 12)),
],
),
)
@@ -53,7 +54,7 @@ class WallpaperSettings extends StatelessWidget {
children: [
Icon(Icons.check_circle, size: 48, color: Colors.white),
SizedBox(height: 8),
Text('自定义壁纸已应用', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
T('自定义壁纸已应用', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
],
),
),
@@ -61,9 +62,9 @@ class WallpaperSettings extends StatelessWidget {
const SizedBox(height: 24),
// 选择图片
const Text('选择壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
T('选择壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
const SizedBox(height: 4),
const Text('从相册选择图片作为应用背景', style: TextStyle(fontSize: 12, color: Colors.grey)),
T('从相册选择图片作为应用背景', style: TextStyle(fontSize: 12, color: Colors.grey)),
const SizedBox(height: 12),
FilledButton.icon(
onPressed: () async {
@@ -77,14 +78,14 @@ class WallpaperSettings extends StatelessWidget {
await provider.setCustomWallpaper(savedPath);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('壁纸已更新'), backgroundColor: Colors.green),
const SnackBar(content: T('壁纸已更新'), backgroundColor: Colors.green),
);
}
}
}
},
icon: const Icon(Icons.photo_library),
label: const Text('选择图片'),
label: T('选择图片'),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
@@ -93,16 +94,16 @@ class WallpaperSettings extends StatelessWidget {
const SizedBox(height: 24),
// 重置
const Text('重置壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
T('重置壁纸', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
const SizedBox(height: 4),
const Text('恢复默认壁纸', style: TextStyle(fontSize: 12, color: Colors.grey)),
T('恢复默认壁纸', style: TextStyle(fontSize: 12, color: Colors.grey)),
const SizedBox(height: 12),
OutlinedButton.icon(
onPressed: () {
_showResetDialog(context, provider);
},
icon: const Icon(Icons.restore),
label: const Text('恢复默认'),
label: T('恢复默认'),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
side: const BorderSide(color: Colors.red),
@@ -131,7 +132,7 @@ class WallpaperSettings extends StatelessWidget {
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('保存失败,请重试')),
const SnackBar(content: T('保存失败,请重试')),
);
}
return null;
@@ -159,12 +160,12 @@ class WallpaperSettings extends StatelessWidget {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('确认重置'),
content: const Text('确定要恢复默认壁纸吗?'),
title: T('确认重置'),
content: T('确定要恢复默认壁纸吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消'),
child: T('取消'),
),
FilledButton(
onPressed: () async {
@@ -172,12 +173,12 @@ class WallpaperSettings extends StatelessWidget {
if (context.mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('已恢复默认壁纸'), backgroundColor: Colors.green),
const SnackBar(content: T('已恢复默认壁纸'), backgroundColor: Colors.green),
);
}
},
style: FilledButton.styleFrom(backgroundColor: Colors.red),
child: const Text('重置'),
child: T('重置'),
),
],
),